Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(151)

Unified Diff: LayoutTests/http/tests/serviceworker/current-on-load.html

Issue 263903005: Fork of https://codereview.chromium.org/265943003 (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | LayoutTests/http/tests/serviceworker/current-on-load-expected.txt » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: LayoutTests/http/tests/serviceworker/current-on-load.html
diff --git a/LayoutTests/http/tests/serviceworker/current-on-load.html b/LayoutTests/http/tests/serviceworker/current-on-load.html
new file mode 100644
index 0000000000000000000000000000000000000000..529e91a1ae0f6c5d7ab4000e29cf7920815c2307
--- /dev/null
+++ b/LayoutTests/http/tests/serviceworker/current-on-load.html
@@ -0,0 +1,43 @@
+<!DOCTYPE html>
+<title>Service Worker: Current on load</title>
+<script src="../resources/testharness.js"></script>
+<script src="../resources/testharnessreport.js"></script>
+<script src="resources/test-helpers.js"></script>
+<script src="resources/testutils.js"></script>
+<body>
+<script>
+var t = async_test('current is set for a controlled document');
+t.step(function() {
+ var scope = 'resources/blank.html'
+ navigator.serviceWorker.unregister(scope).then(
+ doTest,
+ unreached_rejection(t, 'Unregister should not fail')
+ );
+
+ function doTest() {
+ navigator.serviceWorker.register(
+ 'resources/worker-no-op.js', {scope: scope}
+ ).then(
+ onRegister,
+ unreached_rejection(t, 'Registration should succeed, but failed')
+ );
+ }
+
+ function onRegister(worker) {
+ worker.addEventListener('statechange', t.step_func(function(event) {
+ if (event.target.state == 'active')
+ onActive();
+ }));
+ }
+
+ function onActive() {
+ withIframe(scope, t.step_func(function(frame) {
+ var w = frame.contentWindow;
+ assert_true(w.navigator.serviceWorker.current instanceof w.ServiceWorker,
+ 'current should be a ServiceWorker object');
+ t.done();
+ }));
+ }
+});
+</script>
+</body>
« no previous file with comments | « no previous file | LayoutTests/http/tests/serviceworker/current-on-load-expected.txt » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698