Index: third_party/WebKit/LayoutTests/external/wpt/service-workers/service-worker/multi-globals/url-parsing.https.html |
diff --git a/third_party/WebKit/LayoutTests/external/wpt/service-workers/service-worker/multi-globals/url-parsing.https.html b/third_party/WebKit/LayoutTests/external/wpt/service-workers/service-worker/multi-globals/url-parsing.https.html |
new file mode 100644 |
index 0000000000000000000000000000000000000000..1330d07805bb855d3c7ea3ee37cf61c563d7c574 |
--- /dev/null |
+++ b/third_party/WebKit/LayoutTests/external/wpt/service-workers/service-worker/multi-globals/url-parsing.https.html |
@@ -0,0 +1,72 @@ |
+<!DOCTYPE html> |
+<title>register()/getRegistration() URL parsing, with multiple globals in play</title> |
+<link rel="help" href="https://w3c.github.io/ServiceWorker/spec/service_worker/index.html#service-worker-container-register-method"> |
+<link rel="help" href="https://w3c.github.io/ServiceWorker/spec/service_worker/index.html#service-worker-container-getregistration-method"> |
+<link rel="author" title="Domenic Denicola" href="mailto:d@domenic.me"> |
+<script src="/resources/testharness.js"></script> |
+<script src="../resources/testharness-helpers.js"></script> |
+<script src="/resources/testharnessreport.js"></script> |
+<script src="../resources/test-helpers.sub.js"></script> |
+ |
+<!-- This is the entry global --> |
+ |
+<iframe src="incumbent/incumbent.https.html"></iframe> |
+ |
+<script> |
+'use strict'; |
+ |
+const loadPromise = new Promise(resolve => { |
+ window.addEventListener('load', () => resolve()); |
+}); |
+ |
+promise_test(t => { |
+ let registration; |
+ |
+ return loadPromise.then(() => { |
+ return frames[0].testRegister(); |
+ }).then(r => { |
+ registration = r; |
+ const newestWorker = r.installing || r.waiting || r.active; |
+ return wait_for_state(t, newestWorker, 'activated'); |
+ }).then(() => { |
+ return fetch('relevant/test.txt'); |
+ }) |
+ .then(response => response.text()) |
+ .then(text => { |
+ assert_equals(text, 'relevant', |
+ 'the service worker found at relevant/test-sw.js must have been the one to intercept the fetch'); |
+ |
+ return registration.unregister(); |
+ }); |
+}, 'register should use the relevant global of the object it was called on to resolve the script URL'); |
+ |
+promise_test(t => { |
+ return loadPromise.then(() => { |
+ return frames[0].testRegister({ scope: 'scope' }); |
+ }).then(registration => { |
+ assert_equals(registration.scope, normalizeURL('relevant/scope'), 'the scope URL should be relevant/scope'); |
+ |
+ return registration.unregister(); |
+ }); |
+}, 'register should use the relevant global of the object it was called on to resolve the scope URL'); |
+ |
+promise_test(t => { |
+ let registration; |
+ |
+ return loadPromise.then(() => { |
+ return navigator.serviceWorker.register(normalizeURL('relevant/test-sw.js')); |
+ }).then(r => { |
+ registration = r; |
+ return frames[0].testGetRegistration(); |
+ }) |
+ .then(gottenRegistration => { |
+ assert_not_equals(registration, null, 'the registration should not be null'); |
+ assert_not_equals(gottenRegistration, null, 'the registration from the other frame should not be null'); |
+ assert_equals(gottenRegistration.scope, registration.scope, |
+ 'the retrieved registration\'s scope should be equal to the original\'s scope'); |
+ |
+ return registration.unregister(); |
+ }); |
+}, 'getRegistration should use the relevant global of the object it was called on to resolve the script URL'); |
+ |
+</script> |