| Index: LayoutTests/http/tests/serviceworker/chromium/registration.html
|
| diff --git a/LayoutTests/http/tests/serviceworker/chromium/registration.html b/LayoutTests/http/tests/serviceworker/chromium/registration.html
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..0ba621f082f7626df874a8633ec59b7020771804
|
| --- /dev/null
|
| +++ b/LayoutTests/http/tests/serviceworker/chromium/registration.html
|
| @@ -0,0 +1,155 @@
|
| +<!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>
|
| +
|
| +promise_test(function(t) {
|
| + var script = '../resources/no-such-worker.js';
|
| + var scope = '../resources/scope/no-such-worker';
|
| + return navigator.serviceWorker.register(script, {scope: scope})
|
| + .then(
|
| + function() { assert_unreached('Registering non-existent script should fail.'); },
|
| + function(error) {
|
| + assert_equals(error.name, 'NetworkError');
|
| + assert_equals(
|
| + error.message,
|
| + 'Failed to register a ServiceWorker: A bad HTTP response code was received when fetching the script.');
|
| + t.done();
|
| + });
|
| + }, 'Registering non-existent script');
|
| +
|
| +promise_test(function(t) {
|
| + var script = '../resources/invalid-chunked-encoding.php';
|
| + var scope = '../resources/scope/invalid-chunked-encoding/';
|
| + return navigator.serviceWorker.register(script, {scope: scope})
|
| + .then(
|
| + function() { assert_unreached('Registration of invalid chunked encoding script should fail'); },
|
| + function(error) {
|
| + assert_equals(error.name, 'NetworkError');
|
| + assert_equals(error.message, 'Failed to register a ServiceWorker: An unknown error occurred when fetching the script.');
|
| + t.done();
|
| + });
|
| + }, 'Registering invalid chunked encoding script');
|
| +
|
| +promise_test(function(t) {
|
| + var script = '../resources/invalid-chunked-encoding-with-flush.php';
|
| + var scope = '../resources/scope/invalid-chunked-encoding-with-flush/';
|
| + return navigator.serviceWorker.register(script, {scope: scope})
|
| + .then(
|
| + function() { assert_unreached('Registration of invalid chunked encoding script with flush should fail.'); },
|
| + function(error) {
|
| + assert_equals(error.name, 'NetworkError');
|
| + assert_equals(error.message, 'Failed to register a ServiceWorker: An unknown error occurred when fetching the script.');
|
| + t.done();
|
| + });
|
| + }, 'Registering invalid chunked encoding script with flush');
|
| +
|
| +promise_test(function(t) {
|
| + var script = '../resources/plain-text-worker.php';
|
| + var scope = '../resources/scope/plain-text-worker/';
|
| + return navigator.serviceWorker.register(script, {scope: scope})
|
| + .then(
|
| + function() { assert_unreached('Registration of plain text script should fail.'); },
|
| + function(error) {
|
| + assert_equals(error.name, 'SecurityError');
|
| + assert_equals(
|
| + error.message,
|
| + 'Failed to register a ServiceWorker: The script does not have a supported MIME type.');
|
| + t.done();
|
| + });
|
| + }, 'Registering script without correct MIME type');
|
| +
|
| +promise_test(function(t) {
|
| + var script = '../resources/redirect.php?Redirect=' +
|
| + encodeURIComponent('/resources/registration-worker.js');
|
| + var scope = '../resources/scope/redirect/';
|
| + return navigator.serviceWorker.register(script, {scope: scope})
|
| + .then(
|
| + function() { assert_unreached('Registration of redirected script should fail.'); },
|
| + function(error) {
|
| + assert_equals(error.name, 'SecurityError');
|
| + assert_equals(
|
| + error.message,
|
| + 'Failed to register a ServiceWorker: The script resource is behind a redirect, which is disallowed.');
|
| + t.done();
|
| + });
|
| + }, 'Registering redirected script');
|
| +
|
| +promise_test(function(t) {
|
| + var script = '../resources/malformed-worker.php?parse-error';
|
| + var scope = '../resources/scope/parse-error';
|
| + return navigator.serviceWorker.register(script, {scope: scope})
|
| + .then(
|
| + function() { assert_unreached('Registration of script including parse error should fail.'); },
|
| + function(error) {
|
| + assert_equals(error.name, 'AbortError');
|
| + assert_equals(
|
| + error.message,
|
| + 'Failed to register a ServiceWorker: ServiceWorker cannot be started');
|
| + t.done();
|
| + });
|
| + }, 'Registering script including parse error');
|
| +
|
| +promise_test(function(t) {
|
| + var script = '../resources/malformed-worker.php?undefined-error';
|
| + var scope = '../resources/scope/undefined-error';
|
| + return navigator.serviceWorker.register(script, {scope: scope})
|
| + .then(
|
| + function() { assert_unreached('Registration of script including undefined error should fail.'); },
|
| + function(error) {
|
| + assert_equals(error.name, 'AbortError');
|
| + assert_equals(
|
| + error.message,
|
| + 'Failed to register a ServiceWorker: ServiceWorker cannot be started');
|
| + t.done();
|
| + });
|
| + }, 'Registering script including undefined error');
|
| +
|
| +promise_test(function(t) {
|
| + var script = '../resources/malformed-worker.php?uncaught-exception';
|
| + var scope = '../resources/scope/uncaught-exception';
|
| + return navigator.serviceWorker.register(script, {scope: scope})
|
| + .then(
|
| + function() { assert_unreached('Registration of script including uncaught exception should fail.'); },
|
| + function(error) {
|
| + assert_equals(error.name, 'AbortError');
|
| + assert_equals(
|
| + error.message,
|
| + 'Failed to register a ServiceWorker: ServiceWorker cannot be started');
|
| + t.done();
|
| + });
|
| + }, 'Registering script including uncaught exception');
|
| +
|
| +promise_test(function(t) {
|
| + var script = '../resources/malformed-worker.php?import-malformed-script';
|
| + var scope = '../resources/scope/import-malformed-script';
|
| + return navigator.serviceWorker.register(script, {scope: scope})
|
| + .then(
|
| + function() { assert_unreached('Registration of script importing malformed script should fail.'); },
|
| + function(error) {
|
| + assert_equals(error.name, 'AbortError');
|
| + assert_equals(
|
| + error.message,
|
| + 'Failed to register a ServiceWorker: ServiceWorker cannot be started');
|
| + t.done();
|
| + });
|
| + }, 'Registering script importing malformed script');
|
| +
|
| +promise_test(function(t) {
|
| + var script = '../resources/malformed-worker.php?import-no-such-script';
|
| + var scope = '../resources/scope/import-no-such-script';
|
| + return navigator.serviceWorker.register(script, {scope: scope})
|
| + .then(
|
| + function() { assert_unreached('Registration of script importing non-existent script should fail.'); },
|
| + function(error) {
|
| + assert_equals(error.name, 'AbortError');
|
| + assert_equals(
|
| + error.message,
|
| + 'Failed to register a ServiceWorker: ServiceWorker cannot be started');
|
| + t.done();
|
| + });
|
| + }, 'Registering script importing non-existent script');
|
| +</script>
|
|
|