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

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: 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..5e14587019a03015b7f74e90ad7e505fcc487cc9
--- /dev/null
+++ b/LayoutTests/fast/serviceworker/access-container-on-local-file.html
@@ -0,0 +1,39 @@
+<!DOCTYPE html>
+<script src="../../resources/testharness.js"></script>
+<script src="../../resources/testharnessreport.js"></script>
+<script>
+
+async_test(function(t) {
+ var script = 'no-such-worker';
falken 2014/11/12 09:04:41 Doesn't this need to be a "file:///" URL? But then
falken 2014/11/12 09:07:03 Please disregard.
+ navigator.serviceWorker.register(script, { scope: script })
+ .then(function() {
+ assert_unreached('A returned promise should be rejected');
falken 2014/11/12 09:04:41 More grammatical is "The returned promise should b
nhiroki 2014/11/12 09:42:09 Done.
+ }, function(e) {
falken 2014/11/12 09:04:41 Maybe we should assert on the error message conten
falken 2014/11/12 09:07:03 I still think this may be a good idea, WDYT?
nhiroki 2014/11/12 09:42:09 +1! Added the check.
falken 2014/11/13 08:27:55 Ah, sorry. I just realized this was bad advice sin
+ assert_throws(
+ 'SecurityError', function() { throw e; },
+ 'Calling register() on local file should fail');
+ 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('A returned promise should be rejected')
+ }, function(e) {
+ assert_throws(
+ 'SecurityError', function() { throw e; },
+ 'Calling getRegistration() on local file should fail');
+ 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