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

Unified Diff: LayoutTests/http/tests/serviceworker/chromium/registration.html

Issue 849403002: Service Worker: Test of error messages. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 5 years, 11 months 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 | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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>
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698