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

Unified Diff: LayoutTests/fast/serviceworker/access-container-on-local-file.html

Issue 722583002: ServiceWorker: Abort register() and getRegistration() on non-http(s) page (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@fix_get_registration
Patch Set: fix wrong comment Created 6 years, 1 month 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 | Source/modules/serviceworkers/ServiceWorkerContainer.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: LayoutTests/fast/serviceworker/access-container-on-local-file.html
diff --git a/LayoutTests/fast/serviceworker/access-container-on-local-file.html b/LayoutTests/fast/serviceworker/access-container-on-local-file.html
new file mode 100644
index 0000000000000000000000000000000000000000..286d166af584a9f05d59f85d72bf1be9d2e93782
--- /dev/null
+++ b/LayoutTests/fast/serviceworker/access-container-on-local-file.html
@@ -0,0 +1,47 @@
+<!DOCTYPE html>
+<script src="../../resources/testharness.js"></script>
+<script src="../../resources/testharnessreport.js"></script>
+<script>
+
+async_test(function(t) {
+ var script = 'no-such-worker';
+ navigator.serviceWorker.register(script, { scope: script })
+ .then(function() {
+ assert_unreached('register() should fail');
+ }, function(e) {
+ assert_throws(
+ 'SecurityError', function() { throw e; },
+ 'register() on local file should fail');
+ assert_equals(
+ e.message,
+ 'The URL protocol of the current origin is not supported: file',
+ 'register() should fail due to unsupported URL protocol');
+ t.done();
+ })
+ .catch(t.step_func(function(e) {
+ assert_unreached(e);
+ t.done();
+ }));
+}, 'Calling register() on local file');
+
+async_test(function(t) {
+ navigator.serviceWorker.getRegistration()
+ .then(function() {
+ assert_unreached('getRegistration() should fail')
+ }, function(e) {
+ assert_throws(
+ 'SecurityError', function() { throw e; },
+ 'getRegistration() on local file should fail');
+ assert_equals(
+ e.message,
+ 'The URL protocol of the current origin is not supported: file',
+ 'getRegistration() should fail due to unsupported URL protocol');
+ t.done();
+ })
+ .catch(t.step_func(function(e) {
+ assert_unreached(e);
+ t.done();
+ }));
+}, 'Calling getRegistration() on local file');
+
+</script>
« no previous file with comments | « no previous file | Source/modules/serviceworkers/ServiceWorkerContainer.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698