Bug 1495076 [wpt PR 13262] - [Background Fetch] Move CORS preflight check to the controller., a=testonly
authorMugdha Lakhani <nator@chromium.org>
Tue, 09 Oct 2018 04:14:26 +0000
changeset 495965 395605f9fd8d3482287f30ab43bb316e94b76e7f
parent 495964 929c3f751bddb30b55f8393b16f4542d742c91b5
child 495966 c868611cb4ffe6063959d5edfe0cf09091d17c7c
push id9984
push userffxbld-merge
push dateMon, 15 Oct 2018 21:07:35 +0000
treeherdermozilla-beta@183d27ea8570 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerstestonly
bugs1495076, 13262, 889888, 1249265, 596707
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 1495076 [wpt PR 13262] - [Background Fetch] Move CORS preflight check to the controller., a=testonly Automatic update from web-platform-tests[Background Fetch] Move CORS preflight check to the controller. Bug: 889888 Change-Id: I2429361627ffea2e1b8d5a11eb0e34b0cbfa1abb Reviewed-on: https://chromium-review.googlesource.com/c/1249265 Reviewed-by: Joshua Bell <jsbell@chromium.org> Reviewed-by: Rayan Kanso <rayankans@chromium.org> Reviewed-by: Peter Beverloo <peter@chromium.org> Commit-Queue: Mugdha Lakhani <nator@chromium.org> Cr-Commit-Position: refs/heads/master@{#596707} -- wpt-commits: 884ed4baadf3c58d33126793fb7effb2ba974408 wpt-pr: 13262
testing/web-platform/tests/background-fetch/fetch.https.window.js
--- a/testing/web-platform/tests/background-fetch/fetch.https.window.js
+++ b/testing/web-platform/tests/background-fetch/fetch.https.window.js
@@ -80,16 +80,51 @@ backgroundFetchTest(async (test, backgro
   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,
+        new Request('https://example/com', {
+        method: 'PUT',
+      }));
+
+  assert_equals(registration.id, registrationId);
+
+  const {type, eventRegistration, results} = await getMessageFromServiceWorker();
+
+  assert_equals(type, 'backgroundfetchsuccess');
+  assert_equals(eventRegistration.result, 'success');
+  assert_equals(eventRegistration.failureReason, '');
+}, 'Requests with PUT method require CORS Preflight and succeed.');
+
+backgroundFetchTest(async (test, backgroundFetch) => {
+  const registrationId = uniqueId();
+  const registration =
+    await backgroundFetch.fetch(registrationId,
+        new Request('https://example/com', {
+        method: 'POST',
+        headers: {'Content-Type': 'text/json'}
+      }));
+
+  assert_equals(registration.id, registrationId);
+
+  const {type, eventRegistration, results} = await getMessageFromServiceWorker();
+
+  assert_equals(type, 'backgroundfetchsuccess');
+  assert_equals(eventRegistration.result, 'success');
+  assert_equals(eventRegistration.failureReason, '');
+}, 'Requests with text/json content type require CORS Preflight and succeed.');
+
+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, '');