Bug 1492125 [wpt PR 13047] - [Background Fetch] Move mixed content checks to the controller., a=testonly
authorMugdha Lakhani <nator@chromium.org>
Fri, 05 Oct 2018 14:20:54 +0000
changeset 440057 563469d5ab547480dee62e89dc7ea9c780ba44e2
parent 440056 9c5e413320748dd2b3ac3c355f68ff732ca1d760
child 440058 5cfce8016aea36a210a276cd8cad487c353244c7
push id34806
push usernerli@mozilla.com
push dateTue, 09 Oct 2018 04:03:56 +0000
treeherdermozilla-central@6a6c984745ef [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerstestonly
bugs1492125, 13047, 1230025, 595085
milestone64.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1492125 [wpt PR 13047] - [Background Fetch] Move mixed content checks to the controller., a=testonly Automatic update from web-platform-tests[Background Fetch] Move mixed content checks to the controller. Change-Id: Iff2fac58c58042d4ddf55ef962df61954414a1fd Reviewed-on: https://chromium-review.googlesource.com/1230025 Commit-Queue: Mugdha Lakhani <nator@chromium.org> Reviewed-by: Peter Beverloo <peter@chromium.org> Reviewed-by: Dmitry Gozman <dgozman@chromium.org> Reviewed-by: Rayan Kanso <rayankans@chromium.org> Cr-Commit-Position: refs/heads/master@{#595085} -- wpt-commits: 56941492f34854ac48ae5f910e6b1d409a1aa78a wpt-pr: 13047
testing/web-platform/tests/background-fetch/fetch.https.window.js
testing/web-platform/tests/background-fetch/mixed-content-and-allowed-schemes.https.window.js
testing/web-platform/tests/background-fetch/service_workers/sw.js
--- a/testing/web-platform/tests/background-fetch/fetch.https.window.js
+++ b/testing/web-platform/tests/background-fetch/fetch.https.window.js
@@ -65,16 +65,31 @@ backgroundFetchTest(async (test, backgro
     backgroundFetch.fetch('my-id', 'resources/feature-name.txt?2')
   ]));
 
 }, 'IDs must be unique among active Background Fetch registrations');
 
 backgroundFetchTest(async (test, backgroundFetch) => {
   const registrationId = uniqueId();
   const registration =
+    await backgroundFetch.fetch(registrationId, '');
+
+  assert_equals(registration.id, registrationId);
+
+  const {type, eventRegistration, results} = await getMessageFromServiceWorker();
+
+  assert_equals('backgroundfetchsuccess', type);
+  assert_equals(eventRegistration.result, 'success');
+  assert_equals(eventRegistration.failureReason, '');
+
+}, 'Empty URL is OK.');
+
+backgroundFetchTest(async (test, backgroundFetch) => {
+  const registrationId = uniqueId();
+  const registration =
     await backgroundFetch.fetch(registrationId, 'resources/feature-name.txt');
 
   assert_equals(registration.id, registrationId);
   assert_equals(registration.uploadTotal, 0);
   assert_equals(registration.uploaded, 0);
   assert_equals(registration.downloadTotal, 0);
   assert_equals(registration.result, '');
   assert_equals(registration.failureReason, '');
@@ -185,9 +200,25 @@ backgroundFetchTest(async (test, backgro
   assert_true(results[0].url.includes('resources/missing-cat.txt'));
   assert_equals(results[0].status, 404);
   assert_equals(results[0].text, '');
 
   assert_equals(eventRegistration.id, registration.id);
   assert_equals(eventRegistration.result, 'failure');
   assert_equals(eventRegistration.failureReason, 'bad-status');
 
-}, 'Using Background Fetch to fetch a non-existent resource should fail.');
\ No newline at end of file
+}, 'Using Background Fetch to fetch a non-existent resource should fail.');
+
+backgroundFetchTest(async (test, backgroundFetch) => {
+  const registration = await backgroundFetch.fetch(
+                         'my-id',
+                         ['https://example.com', 'http://example.com']);
+
+  const {type, eventRegistration, results} = await getMessageFromServiceWorker();
+
+  assert_equals('backgroundfetchfail', type);
+  assert_equals(eventRegistration.failureReason, 'fetch-error');
+
+  assert_equals(results.length, 2);
+  assert_true(results[0].url.includes('https://example.com'));
+  assert_equals(results[1].url, '');
+
+}, 'Fetches with mixed content should fail.');
--- a/testing/web-platform/tests/background-fetch/mixed-content-and-allowed-schemes.https.window.js
+++ b/testing/web-platform/tests/background-fetch/mixed-content-and-allowed-schemes.https.window.js
@@ -27,44 +27,16 @@ backgroundFetchTest((t, bgFetch) => {
 }, 'loopback IPv6 http: fetch should register ok');
 
 backgroundFetchTest((t, bgFetch) => {
   return bgFetch.fetch(uniqueId(), 'http://localhost');
 }, 'localhost http: fetch should register ok');
 
 backgroundFetchTest((t, bgFetch) => {
   return promise_rejects(t, new TypeError(),
-                         bgFetch.fetch(uniqueId(), 'http://example.com'));
-}, 'non-loopback http: fetch should reject');
-
-backgroundFetchTest((t, bgFetch) => {
-  return promise_rejects(t, new TypeError(),
-                         bgFetch.fetch(uniqueId(), 'http://192.0.2.0'));
-}, 'non-loopback IPv4 http: fetch should reject');
-
-backgroundFetchTest((t, bgFetch) => {
-  return promise_rejects(t, new TypeError(),
-                         bgFetch.fetch(uniqueId(), 'http://[2001:db8::1]'));
-}, 'non-loopback IPv6 http: fetch should reject');
-
-backgroundFetchTest((t, bgFetch) => {
-  return promise_rejects(t, new TypeError(),
-                         bgFetch.fetch(uniqueId(), ['https://example.com',
-                                                    'http://example.com']));
-}, 'https: and non-loopback http: fetch should reject');
-
-backgroundFetchTest((t, bgFetch) => {
-  return promise_rejects(t, new TypeError(),
-                         bgFetch.fetch(uniqueId(), ['http://example.com',
-                                                    'https://example.com']));
-}, 'non-loopback http: and https: fetch should reject');
-
-
-backgroundFetchTest((t, bgFetch) => {
-  return promise_rejects(t, new TypeError(),
                          bgFetch.fetch(uniqueId(), 'wss:127.0.0.1'));
 }, 'wss: fetch should reject');
 
 backgroundFetchTest((t, bgFetch) => {
   return promise_rejects(t, new TypeError(),
                          bgFetch.fetch(uniqueId(), 'file:///'));
 }, 'file: fetch should reject');
 
--- a/testing/web-platform/tests/background-fetch/service_workers/sw.js
+++ b/testing/web-platform/tests/background-fetch/service_workers/sw.js
@@ -22,10 +22,8 @@ function handleBackgroundFetchUpdateEven
         const registrationCopy = cloneRegistration(event.registration);
         sendMessageToDocument(
           { type: event.type, eventRegistration: registrationCopy, results })
       }));
 }
 
 self.addEventListener('backgroundfetchsuccess', handleBackgroundFetchUpdateEvent);
 self.addEventListener('backgroundfetchfail', handleBackgroundFetchUpdateEvent);
-
-