| Index: LayoutTests/http/tests/serviceworker/registration.html
|
| diff --git a/LayoutTests/http/tests/serviceworker/registration.html b/LayoutTests/http/tests/serviceworker/registration.html
|
| index 5d15d6f21ba8047379c1f1d9f274e3bbbe4765a8..34821c8a84628d4742ec39a124303085b7931630 100644
|
| --- a/LayoutTests/http/tests/serviceworker/registration.html
|
| +++ b/LayoutTests/http/tests/serviceworker/registration.html
|
| @@ -1,119 +1,78 @@
|
| <!DOCTYPE html>
|
| <title>Service Worker: Registration</title>
|
| <script src="../resources/testharness.js"></script>
|
| +<script src="../resources/testharness-helpers.js"></script>
|
| <script src="../resources/testharnessreport.js"></script>
|
| <script src="resources/test-helpers.js"></script>
|
| <script>
|
| -(function() {
|
| - var t = async_test('Registering normal pattern');
|
| - t.step(function() {
|
| - var scope = '/registration/';
|
| - navigator.serviceWorker.register(
|
| - 'resources/registration-worker.js',
|
| - {scope: scope}
|
| - ).then(
|
| - t.step_func(function(registration) {
|
| - assert_true(registration instanceof ServiceWorkerRegistration,
|
| - 'Successfully registered.');
|
| - service_worker_unregister_and_done(t, scope);
|
| - }),
|
| - t.step_func(function(reason) {
|
| - assert_unreached('Registration should succeed, but failed: ' + reason.name);
|
| - })
|
| - );
|
| - });
|
| -}());
|
| +
|
| +promise_test(function(t) {
|
| + var script = 'resources/registration-worker.js';
|
| + var scope = '/registration/';
|
| + return navigator.serviceWorker.register(script, {scope: scope})
|
| + .then(function(registration) {
|
| + assert_true(registration instanceof ServiceWorkerRegistration,
|
| + 'Successfully registered.');
|
| + service_worker_unregister_and_done(t, scope);
|
| + })
|
| + }, 'Registering normal pattern');
|
|
|
| -(function() {
|
| - var t = async_test('Registering scope outside domain');
|
| - t.step(function() {
|
| - navigator.serviceWorker.register(
|
| - 'resources/registration-worker.js',
|
| - {scope: 'http://example.com/'}
|
| - ).then(
|
| - t.step_func(function(registration) {
|
| - assert_unreached('Registration scope outside domain should fail.');
|
| - }),
|
| - t.step_func(function(reason) {
|
| - assert_equals(reason.name, 'SecurityError',
|
| - 'Registration scope outside domain should fail with SecurityError.');
|
| - t.done();
|
| - })
|
| - );
|
| - });
|
| -}());
|
| +promise_test(function(t) {
|
| + var script = 'resources/registration-worker.js';
|
| + var scope = 'http://example.com/';
|
| + return assert_promise_rejects(
|
| + navigator.serviceWorker.register(script, {scope: scope}),
|
| + 'SecurityError',
|
| + 'Registration scope outside domain should fail with SecurityError.');
|
| + }, 'Registering scope outside domain');
|
|
|
| -(function() {
|
| - var t = async_test('Registering script outside domain');
|
| - t.step(function() {
|
| - navigator.serviceWorker.register(
|
| - 'http://example.com/worker.js'
|
| - ).then(
|
| - t.step_func(function(registration) {
|
| - assert_unreached('Registration script outside domain should fail.');
|
| - }),
|
| - t.step_func(function(reason) {
|
| - assert_equals(reason.name, 'SecurityError',
|
| - 'Registration script outside domain should fail with SecurityError.');
|
| - t.done();
|
| - })
|
| - );
|
| - });
|
| -}());
|
| +promise_test(function(t) {
|
| + var script = 'http://example.com/worker.js';
|
| + return assert_promise_rejects(
|
| + navigator.serviceWorker.register(script),
|
| + 'SecurityError',
|
| + 'Registration script outside domain should fail with SecurityError.');
|
| + }, 'Registering script outside domain');
|
|
|
| -(function() {
|
| - var t = async_test('Registering non-existent script');
|
| - t.step(function() {
|
| - navigator.serviceWorker.register(
|
| - 'resources/no-such-worker.js'
|
| - ).then(
|
| - t.step_func(function(registration) {
|
| - assert_unreached('Registration of non-existent script should fail.');
|
| - }),
|
| - t.step_func(function(reason) {
|
| - assert_equals(reason.name, 'NetworkError',
|
| - 'Registration of non-existent script should fail.');
|
| - t.done();
|
| - })
|
| - );
|
| - });
|
| -}());
|
| +promise_test(function(t) {
|
| + var script = 'no-such-worker.js';
|
| + return assert_promise_rejects(
|
| + navigator.serviceWorker.register(script),
|
| + 'NetworkError',
|
| + 'Registration of non-existent script should fail.');
|
| + }, 'Registering non-existent script');
|
|
|
| -(function() {
|
| - var t = async_test('Registering script without correct MIME type');
|
| - t.step(function() {
|
| - navigator.serviceWorker.register(
|
| - 'resources/plain-text-worker.php'
|
| - ).then(
|
| - t.step_func(function(registration) {
|
| - assert_unreached('Registration of plain text script should fail.');
|
| - }),
|
| - t.step_func(function(reason) {
|
| - assert_equals(reason.name, 'SecurityError',
|
| - 'Registration of plain text script should fail.');
|
| - t.done();
|
| - })
|
| - );
|
| - });
|
| -}());
|
| +promise_test(function(t) {
|
| + var script = 'resources/invalid-chunked-encoding.php';
|
| + return assert_promise_rejects(
|
| + navigator.serviceWorker.register(script),
|
| + 'NetworkError',
|
| + 'Registration of invalid chunked encoding script should fail.');
|
| + }, 'Registering invalid chunked encoding script');
|
|
|
| -(function() {
|
| - var t = async_test('Registering redirected script');
|
| - t.step(function() {
|
| - navigator.serviceWorker.register(
|
| - 'resources/redirect.php?Redirect=' +
|
| - encodeURIComponent('/resources/registration-worker.js')
|
| - ).then(
|
| - t.step_func(function(registration) {
|
| - assert_unreached('Registration of redirected script should fail.');
|
| - }),
|
| - t.step_func(function(reason) {
|
| - assert_equals(reason.name, 'SecurityError',
|
| - 'Registration of redirected script should fail.');
|
| - t.done();
|
| - })
|
| - );
|
| - });
|
| -}());
|
| +promise_test(function(t) {
|
| + var script = 'resources/invalid-chunked-encoding-with-flush.php';
|
| + return assert_promise_rejects(
|
| + navigator.serviceWorker.register(script),
|
| + 'NetworkError',
|
| + 'Registration of invalid chunked encoding script should fail.');
|
| + }, 'Registering invalid chunked encoding script with flush');
|
| +
|
| +promise_test(function(t) {
|
| + var script = 'resources/plain-text-worker.php';
|
| + return assert_promise_rejects(
|
| + navigator.serviceWorker.register(script),
|
| + 'SecurityError',
|
| + 'Registration of plain text script should fail.');
|
| + }, 'Registering script without correct MIME type');
|
| +
|
| +promise_test(function(t) {
|
| + var script = 'resources/redirect.php?Redirect=' +
|
| + encodeURIComponent('/resources/registration-worker.js');
|
| + return assert_promise_rejects(
|
| + navigator.serviceWorker.register(script),
|
| + 'SecurityError',
|
| + 'Registration of redirected script should fail.');
|
| + }, 'Registering redirected script');
|
|
|
| </script>
|
|
|