Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge r228241 - ASSERTION FAILED: m_timeOrigin in Performance::Perfor…
…mance() https://bugs.webkit.org/show_bug.cgi?id=182558 <rdar://problem/37297551> Patch by Youenn Fablet <youenn@apple.com> on 2018-02-07 Reviewed by Chris Dumez. Source/WebCore: Test: http/wpt/fetch/cors-preflight-star.any.serviceworker.html * loader/CrossOriginPreflightChecker.cpp: (WebCore::CrossOriginPreflightChecker::startPreflight): LayoutTests: Make use of WPT cors-preflight-star.any.js test in service worker. This test should be removed once WPT will run any.js tests in service workers as well as workers and window. * http/wpt/service-workers/cors-preflight-star.any.js: Added. * http/wpt/service-workers/cors-preflight-star.any.serviceworker-expected.txt: Added. * http/wpt/service-workers/cors-preflight-star.any.serviceworker.html: Added.
- Loading branch information
1 parent
74e1ceb
commit 07e92c6
Showing
6 changed files
with
119 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
44 changes: 44 additions & 0 deletions
44
LayoutTests/http/wpt/service-workers/cors-preflight-star.any.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
// META: script=/fetch/api/resources/utils.js | ||
// META: script=/common/get-host-info.sub.js | ||
|
||
const url = get_host_info().HTTP_REMOTE_ORIGIN + dirname(location.pathname) + RESOURCES_DIR + "preflight.py", | ||
origin = location.origin // assuming an ASCII origin | ||
|
||
function preflightTest(succeeds, withCredentials, allowMethod, allowHeader, useMethod, useHeader) { | ||
return promise_test(t => { | ||
let testURL = url + "?", | ||
requestInit = {} | ||
if (withCredentials) { | ||
testURL += "origin=" + origin + "&" | ||
testURL += "credentials&" | ||
requestInit.credentials = "include" | ||
} | ||
if (useMethod) { | ||
requestInit.method = useMethod | ||
} | ||
if (useHeader.length > 0) { | ||
requestInit.headers = [useHeader] | ||
} | ||
testURL += "allow_methods=" + allowMethod + "&" | ||
testURL += "allow_headers=" + allowHeader + "&" | ||
|
||
if (succeeds) { | ||
return fetch(testURL, requestInit).then(resp => { | ||
assert_equals(resp.headers.get("x-origin"), origin) | ||
}) | ||
} else { | ||
return promise_rejects(t, new TypeError(), fetch(testURL, requestInit)) | ||
} | ||
}, "CORS that " + (succeeds ? "succeeds" : "fails") + " with credentials: " + withCredentials + "; method: " + useMethod + " (allowed: " + allowMethod + "); header: " + useHeader + " (allowed: " + allowHeader + ")") | ||
} | ||
|
||
preflightTest(true, false, "get", "x-test", "GET", ["X-Test", "1"]) | ||
preflightTest(true, false, "*", "x-test", "SUPER", ["X-Test", "1"]) | ||
preflightTest(true, false, "*", "*", "OK", ["X-Test", "1"]) | ||
preflightTest(false, true, "*", "*", "OK", ["X-Test", "1"]) | ||
preflightTest(false, true, "*", "", "PUT", []) | ||
preflightTest(true, true, "PUT", "*", "PUT", []) | ||
preflightTest(false, true, "put", "*", "PUT", []) | ||
preflightTest(false, true, "get", "*", "GET", ["X-Test", "1"]) | ||
preflightTest(false, true, "*", "*", "GET", ["X-Test", "1"]) | ||
preflightTest(true, true, "*", "*", "*", ["*", "1"]) |
13 changes: 13 additions & 0 deletions
13
LayoutTests/http/wpt/service-workers/cors-preflight-star.any.serviceworker-expected.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
|
||
PASS Setting up tests | ||
FAIL CORS that succeeds with credentials: false; method: GET (allowed: get); header: X-Test,1 (allowed: x-test) promise_test: Unhandled rejection with value: object "TypeError: Preflight response is not successful" | ||
FAIL CORS that succeeds with credentials: false; method: SUPER (allowed: *); header: X-Test,1 (allowed: x-test) promise_test: Unhandled rejection with value: object "TypeError: Preflight response is not successful" | ||
FAIL CORS that succeeds with credentials: false; method: OK (allowed: *); header: X-Test,1 (allowed: *) promise_test: Unhandled rejection with value: object "TypeError: Preflight response is not successful" | ||
PASS CORS that fails with credentials: true; method: OK (allowed: *); header: X-Test,1 (allowed: *) | ||
PASS CORS that fails with credentials: true; method: PUT (allowed: *); header: (allowed: ) | ||
FAIL CORS that succeeds with credentials: true; method: PUT (allowed: PUT); header: (allowed: *) promise_test: Unhandled rejection with value: object "TypeError: Preflight response is not successful" | ||
PASS CORS that fails with credentials: true; method: PUT (allowed: put); header: (allowed: *) | ||
PASS CORS that fails with credentials: true; method: GET (allowed: get); header: X-Test,1 (allowed: *) | ||
PASS CORS that fails with credentials: true; method: GET (allowed: *); header: X-Test,1 (allowed: *) | ||
FAIL CORS that succeeds with credentials: true; method: * (allowed: *); header: *,1 (allowed: *) promise_test: Unhandled rejection with value: object "TypeError: Preflight response is not successful" | ||
|
33 changes: 33 additions & 0 deletions
33
LayoutTests/http/wpt/service-workers/cors-preflight-star.any.serviceworker.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<title>Service Worker: Fetch API CORS preflight tests</title> | ||
</head> | ||
<body> | ||
<script src="/resources/testharness.js"></script> | ||
<script src="/resources/testharnessreport.js"></script> | ||
<script src="/service-workers/service-worker/resources/test-helpers.sub.js"></script> | ||
<script> | ||
'use strict'; | ||
|
||
// FIXME: Remove this test once https://github.com/w3c/web-platform-tests/issues/4210 is resolved. | ||
promise_test(async (t) => { | ||
var url = 'cors-preflight-star.any.worker.js'; | ||
var scope = 'empty.html'; | ||
var frame_sw, sw_registration; | ||
|
||
await service_worker_unregister(t, scope); | ||
var f = await with_iframe(scope); | ||
t.add_cleanup(function() { | ||
f.remove(); | ||
}); | ||
frame_sw = f.contentWindow.navigator.serviceWorker; | ||
var registration = await navigator.serviceWorker.register(url, {scope: scope}); | ||
sw_registration = registration; | ||
await wait_for_state(t, registration.installing, 'activated'); | ||
fetch_tests_from_worker(sw_registration.active); | ||
}, 'Setting up tests'); | ||
|
||
</script> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters