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> |