forked from mozilla/gecko-dev
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Bug 1357290 - move test_update_missing_imported_script.html to WPT r=…
…edenchuang Differential Revision: https://phabricator.services.mozilla.com/D6439 --HG-- extra : moz-landing-system : lando
- Loading branch information
1 parent
1b83282
commit 96d721e
Showing
7 changed files
with
55 additions
and
146 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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
87 changes: 0 additions & 87 deletions
87
dom/serviceworkers/test/test_update_missing_imported_script.html
This file was deleted.
Oops, something went wrong.
9 changes: 9 additions & 0 deletions
9
...service-workers/service-worker/resources/update-missing-import-scripts-imported-worker.py
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,9 @@ | ||
def main(request, response): | ||
key = request.GET['key'] | ||
already_requested = request.server.stash.take(key) | ||
|
||
if already_requested is None: | ||
request.server.stash.put(key, True) | ||
return [('Content-Type', 'application/javascript')], '// initial script' | ||
|
||
response.status = (404, 'Not found: should not have been able to import this script twice!') |
13 changes: 13 additions & 0 deletions
13
...sts/service-workers/service-worker/resources/update-missing-import-scripts-main-worker.py
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 @@ | ||
def main(request, response): | ||
key = request.GET['key'] | ||
already_requested = request.server.stash.take(key) | ||
|
||
header = [('Content-Type', 'application/javascript')] | ||
initial_script = 'importScripts("./update-missing-import-scripts-imported-worker.py?key={0}")'.format(key) | ||
updated_script = '// removed importScripts()' | ||
|
||
if already_requested is None: | ||
request.server.stash.put(key, True) | ||
return header, initial_script | ||
|
||
return header, updated_script |
33 changes: 33 additions & 0 deletions
33
...eb-platform/tests/service-workers/service-worker/update-missing-import-scripts.https.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> | ||
<title>Service Worker: update with missing importScripts</title> | ||
<script src="/resources/testharness.js"></script> | ||
<script src="/resources/testharnessreport.js"></script> | ||
<script src="resources/test-helpers.sub.js"></script> | ||
<script src="/common/utils.js"></script> | ||
<body> | ||
<script> | ||
/** | ||
* Test ServiceWorkerRegistration.update() when importScripts in a service worker | ||
* script is no longer available (but was initially). | ||
*/ | ||
let registration = null; | ||
|
||
promise_test(async (test) => { | ||
const script = `resources/update-missing-import-scripts-main-worker.py?key=${token()}`; | ||
const scope = 'resources/update-missing-import-scripts'; | ||
|
||
registration = await service_worker_unregister_and_register(test, script, scope); | ||
|
||
add_completion_callback(() => { registration.unregister(); }); | ||
|
||
await wait_for_state(test, registration.installing, 'activated'); | ||
}, 'Initialize global state'); | ||
|
||
promise_test(test => { | ||
return new Promise(resolve => { | ||
registration.addEventListener('updatefound', resolve); | ||
registration.update(); | ||
}); | ||
}, 'Update service worker with new script that\'s missing importScripts()'); | ||
</script> | ||
</body> |