Chromium Code Reviews| Index: LayoutTests/http/tests/serviceworker/registration.html |
| diff --git a/LayoutTests/http/tests/serviceworker/registration.html b/LayoutTests/http/tests/serviceworker/registration.html |
| index b1459e99ba8677062eaa6da960d9af629ec6f3d5..f932c9e8fd22a2d3a5c44f8490dc69b99eb5f385 100644 |
| --- a/LayoutTests/http/tests/serviceworker/registration.html |
| +++ b/LayoutTests/http/tests/serviceworker/registration.html |
| @@ -1,48 +1,45 @@ |
| -<html> |
| -<head> |
| -<script src="/js-test-resources/js-test.js"></script> |
| -</head> |
| -<body> |
| +<!DOCTYPE html> |
|
dominicc (has gone to gerrit)
2014/04/09 20:09:08
My favorite file, this is a nice set of sweet litt
jsbell
2014/04/09 23:04:40
Originally written by kinuko, obviously. :)
|
| +<title>Service Worker: Registration</title> |
| +<script src="../resources/testharness.js"></script> |
| +<script src="../resources/testharnessreport.js"></script> |
| <script> |
| - description("Tests if ServiceWorker registration is working") |
| +var test_registerBasics = async_test('Registering normal pattern'); |
| +test_registerBasics.step(function() { |
| + navigator.serviceWorker.register('resources/registration-worker.js', |
| + {scope: '/*'}).then( |
| + test_registerBasics.step_func(function(worker) { |
|
dominicc (has gone to gerrit)
2014/04/09 20:09:08
BTW, inside step/step_func I think you can use 'th
jsbell
2014/04/09 23:04:40
Having tried both, I think I like your `var t` sty
|
| + assert_true(!!worker, 'Successfully registered'); |
|
dominicc (has gone to gerrit)
2014/04/09 20:09:08
Can we make this more useful, eg !!worker -> worke
jsbell
2014/04/09 23:04:40
I had the 'instanceof' test, actually, but the IDL
|
| + test_registerBasics.done(); |
| + }), |
| + test_registerBasics.step_func(function(reason) { |
| + assert_equals(reason.name, 'DisabledError'); |
| + test_registerBasics.done(); |
| + })); |
| +}); |
| + |
| +var test_registerPatternOutsideDomain = async_test('Registering pattern outside domain'); |
| +test_registerPatternOutsideDomain.step(function() { |
| + navigator.serviceWorker.register('resources/registration-worker.js', |
| + {scope: 'http://example.com/*'}).then( |
| + test_registerPatternOutsideDomain.step_func(function(worker) { |
| + assert_unreached('Registration outside domain should fail'); |
| + }), |
| + test_registerPatternOutsideDomain.step_func(function(reason) { |
| + assert_equals(reason.name, 'SecurityError'); |
| + test_registerPatternOutsideDomain.done(); |
| + })); |
| +}); |
| + |
| +var test_registerScriptOutsideDomain = async_test('Registering script outside domain'); |
| +test_registerScriptOutsideDomain.step(function() { |
| + navigator.serviceWorker.register('http://example.com/worker.js').then( |
| + test_registerScriptOutsideDomain.step_func(function(worker) { |
| + assert_unreached('Registration outside domain should fail'); |
| + }), |
| + test_registerScriptOutsideDomain.step_func(function(reason) { |
| + assert_equals(reason.name, 'SecurityError'); |
| + test_registerScriptOutsideDomain.done(); |
| + })); |
| +}); |
| - function test_registerBasics() { |
| - debug("Registering normal pattern"); |
| - return navigator.serviceWorker.register("serviceworker.js", {scope:"/*"}).then( |
| - function(worker) { |
| - debug("Successfully registered"); |
| - return worker; |
| - }, |
| - function(e) { |
| - regError = e; |
| - shouldBe("'DisabledError'", "regError.name"); |
| - }); |
| - } |
| - function test_registerPatternOutsideDomain() { |
| - debug("Registering pattern outside domain"); |
| - return navigator.serviceWorker.register("serviceworker.js", {scope:"http://foo.com/*"}) |
| - .catch(function(e) { |
| - regError = e; |
| - shouldBe("'SecurityError'", "regError.name"); |
| - }); |
| - } |
| - function test_registerScriptOutsideDomain() { |
| - debug("Registering pattern outside domain"); |
| - return navigator.serviceWorker.register("http://foo.com/serviceworker.js") |
| - .catch(function(e) { |
| - regError = e; |
| - shouldBe("'SecurityError'", "regError.name"); |
| - }); |
| - } |
| - var jsTestIsAsync = true; |
| - test_registerBasics() |
| - .then(test_registerPatternOutsideDomain) |
| - .then(test_registerScriptOutsideDomain) |
| - .then(finishJSTest, function(e) { |
| - testFailed("Tests failed, exited with error:" + e.name + ": " + e.message); |
| - finishJSTest(); |
| - }); |
| </script> |
| -<script src="/js-test-resources/js-test-post.js"></script> |
| -</body> |
| -</html> |