Skip to content

Commit

Permalink
Merge r228241 - ASSERTION FAILED: m_timeOrigin in Performance::Perfor…
Browse files Browse the repository at this point in the history
…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
youennf authored and carlosgcampos committed Feb 19, 2018
1 parent 74e1ceb commit 07e92c6
Show file tree
Hide file tree
Showing 6 changed files with 119 additions and 0 deletions.
15 changes: 15 additions & 0 deletions LayoutTests/ChangeLog
@@ -1,3 +1,18 @@
2018-02-07 Youenn Fablet <youenn@apple.com>

ASSERTION FAILED: m_timeOrigin in Performance::Performance()
https://bugs.webkit.org/show_bug.cgi?id=182558
<rdar://problem/37297551>

Reviewed by Chris Dumez.

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.

2018-02-07 Chris Dumez <cdumez@apple.com>

IndexedDB in service workers is using a memory backed store
Expand Down
44 changes: 44 additions & 0 deletions LayoutTests/http/wpt/service-workers/cors-preflight-star.any.js
@@ -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"])
@@ -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"

@@ -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>
13 changes: 13 additions & 0 deletions Source/WebCore/ChangeLog
@@ -1,3 +1,16 @@
2018-02-07 Youenn Fablet <youenn@apple.com>

ASSERTION FAILED: m_timeOrigin in Performance::Performance()
https://bugs.webkit.org/show_bug.cgi?id=182558
<rdar://problem/37297551>

Reviewed by Chris Dumez.

Test: http/wpt/fetch/cors-preflight-star.any.serviceworker.html

* loader/CrossOriginPreflightChecker.cpp:
(WebCore::CrossOriginPreflightChecker::startPreflight):

2018-02-07 Zalan Bujtas <zalan@apple.com>

[RenderTreeBuilder] Remove RenderElement::destroyLeftoverChildren.
Expand Down
1 change: 1 addition & 0 deletions Source/WebCore/loader/CrossOriginPreflightChecker.cpp
Expand Up @@ -108,6 +108,7 @@ void CrossOriginPreflightChecker::startPreflight()
options.referrerPolicy = m_loader.options().referrerPolicy;
options.contentSecurityPolicyImposition = ContentSecurityPolicyImposition::SkipPolicyCheck;
options.serviceWorkersMode = ServiceWorkersMode::None;
options.initiatorContext = m_loader.options().initiatorContext;

CachedResourceRequest preflightRequest(createAccessControlPreflightRequest(m_request, m_loader.securityOrigin(), m_loader.referrer()), options);
if (RuntimeEnabledFeatures::sharedFeatures().resourceTimingEnabled())
Expand Down

0 comments on commit 07e92c6

Please sign in to comment.