OLD | NEW |
(Empty) | |
| 1 <html> |
| 2 <head> |
| 3 <script src="/js-test-resources/js-test-pre.js"></script> |
| 4 </head> |
| 5 <body> |
| 6 <script> |
| 7 description("Tests if ServiceWorker registration is working") |
| 8 |
| 9 function test_registerBasics() { |
| 10 debug("Registering normal pattern"); |
| 11 return navigator.registerServiceWorker("/*", "serviceworker.js").then( |
| 12 function(worker) { |
| 13 debug("Successfully registered"); |
| 14 return worker; |
| 15 }, |
| 16 function(e) { |
| 17 regError = e; |
| 18 shouldBe("'DisabledError'", "regError.name"); |
| 19 }); |
| 20 } |
| 21 function test_registerPatternOutsideDomain() { |
| 22 debug("Registering pattern outside domain"); |
| 23 return navigator.registerServiceWorker("http://foo.com/*", "servicewor
ker.js") |
| 24 .catch(function(e) { |
| 25 regError = e; |
| 26 shouldBe("'SecurityError'", "regError.name"); |
| 27 }); |
| 28 } |
| 29 function test_registerScriptOutsideDomain() { |
| 30 debug("Registering pattern outside domain"); |
| 31 return navigator.registerServiceWorker("/*", "http://foo.com/servicewo
rker.js") |
| 32 .catch(function(e) { |
| 33 regError = e; |
| 34 shouldBe("'SecurityError'", "regError.name"); |
| 35 }); |
| 36 } |
| 37 var jsTestIsAsync = true; |
| 38 test_registerBasics() |
| 39 .then(test_registerPatternOutsideDomain) |
| 40 .then(test_registerScriptOutsideDomain) |
| 41 .then(finishJSTest, function(e) { |
| 42 testFailed("Tests failed, exited with error:" + e.name + ": " + e.mess
age); |
| 43 finishJSTest(); |
| 44 }); |
| 45 </script> |
| 46 <script src="/js-test-resources/js-test-post.js"></script> |
| 47 </body> |
| 48 </html> |
OLD | NEW |