зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1180754 - Get serviceworkerobject-scripturl test passing. r=bkelly
This commit does several things: 1. Change to https so the test does not fail due to security exceptions. 2. Change function service_worker_unregister to get around the "getRegistration() matches most specific registration" issue by matching exact scope. 3. Uses the URL object for the "absolute" test instead of relying on server substitution since it achieves the same thing. 4. Allows fragments in the scriptURL since I cannot find anything in the spec preventing this. I have filed https://github.com/slightlyoff/ServiceWorker/issues/742 to resolve this. Update web-platform-tests expected data --HG-- rename : testing/web-platform/mozilla/tests/service-workers/service-worker/serviceworkerobject-scripturl.sub.html => testing/web-platform/mozilla/tests/service-workers/service-worker/serviceworkerobject-scripturl.https.html extra : commitid : FdkKoMW3YAD extra : rebase_source : bbece1fa3fd431ef8102b5edd154387416e4eef6 extra : source : dd3fd15e5522ce319fe4f6387934e8664b14a0be
This commit is contained in:
Родитель
bc7c1ee7ee
Коммит
34d95d44bf
|
@ -436,10 +436,10 @@
|
|||
"url": "/_mozilla/service-workers/service-worker/service-worker-csp-script.https.html"
|
||||
}
|
||||
],
|
||||
"service-workers/service-worker/serviceworkerobject-scripturl.sub.html": [
|
||||
"service-workers/service-worker/serviceworkerobject-scripturl.https.html": [
|
||||
{
|
||||
"path": "service-workers/service-worker/serviceworkerobject-scripturl.sub.html",
|
||||
"url": "/_mozilla/service-workers/service-worker/serviceworkerobject-scripturl.sub.html"
|
||||
"path": "service-workers/service-worker/serviceworkerobject-scripturl.https.html",
|
||||
"url": "/_mozilla/service-workers/service-worker/serviceworkerobject-scripturl.https.html"
|
||||
}
|
||||
],
|
||||
"service-workers/service-worker/shared-worker-controlled.https.html": [
|
||||
|
@ -552,4 +552,4 @@
|
|||
"rev": null,
|
||||
"url_base": "/_mozilla/",
|
||||
"version": 2
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,11 +0,0 @@
|
|||
[serviceworkerobject-scripturl.sub.html]
|
||||
type: testharness
|
||||
[Verify the scriptURL property: relative]
|
||||
expected: FAIL
|
||||
|
||||
[Verify the scriptURL property: with-fragment]
|
||||
expected: FAIL
|
||||
|
||||
[Verify the scriptURL property: absolute]
|
||||
expected: FAIL
|
||||
|
|
@ -13,10 +13,13 @@ function service_worker_unregister_and_register(test, url, scope) {
|
|||
'unregister and register should not fail'));
|
||||
}
|
||||
|
||||
function service_worker_unregister(test, documentUrl) {
|
||||
return navigator.serviceWorker.getRegistration(documentUrl)
|
||||
// This unregisters the registration that precisely matches scope. Use this
|
||||
// when unregistering by scope. If no registration is found, it just resolves.
|
||||
function service_worker_unregister(test, scope) {
|
||||
var absoluteScope = (new URL(scope, window.location).href);
|
||||
return navigator.serviceWorker.getRegistration(scope)
|
||||
.then(function(registration) {
|
||||
if (registration)
|
||||
if (registration && registration.scope === absoluteScope)
|
||||
return registration.unregister();
|
||||
})
|
||||
.catch(unreached_rejection(test, 'unregister should not fail'));
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
function url_test(name, url) {
|
||||
var scope = 'resources/scope/' + name;
|
||||
async_test(function(t) {
|
||||
var expectedURL = normalizeURL(url);
|
||||
var expectedURL = (new URL(url, window.location)).toString();
|
||||
service_worker_unregister_and_register(t, url, scope)
|
||||
.then(function(registration) {
|
||||
var worker = registration.installing;
|
||||
|
@ -22,7 +22,6 @@ function url_test(name, url) {
|
|||
|
||||
url_test('relative', 'resources/empty-worker.js');
|
||||
url_test('with-fragment', 'resources/empty-worker.js#ref');
|
||||
url_test('absolute',
|
||||
'http://{{domains[www]}}:{{ports[http][0]}}/service-worker/resources/empty-worker.js');
|
||||
url_test('absolute', (new URL('./resources/empty-worker.js', window.location)).href);
|
||||
|
||||
</script>
|
Загрузка…
Ссылка в новой задаче