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

Unified Diff: third_party/WebKit/LayoutTests/http/tests/serviceworker/resources/registration-tests.js

Issue 1926813004: Replace assert_promise_rejects with upstream promise_rejects. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: remove all testharness-helpers.js references Created 4 years, 7 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
Index: third_party/WebKit/LayoutTests/http/tests/serviceworker/resources/registration-tests.js
diff --git a/third_party/WebKit/LayoutTests/http/tests/serviceworker/resources/registration-tests.js b/third_party/WebKit/LayoutTests/http/tests/serviceworker/resources/registration-tests.js
index 09e1b5e83cc073d678fe39d339bfa4407b2e08f0..18ba45c80bb349c6779b82bc2979c48216a3a82d 100644
--- a/third_party/WebKit/LayoutTests/http/tests/serviceworker/resources/registration-tests.js
+++ b/third_party/WebKit/LayoutTests/http/tests/serviceworker/resources/registration-tests.js
@@ -57,9 +57,9 @@ function registration_tests(register_method, check_error_types) {
promise_test(function(t) {
var script = 'resources/registration-worker.js';
var scope = 'resources';
- return assert_promise_rejects(
- register_method(script, {scope: scope}),
+ return promise_rejects(t,
check_error_types ? 'SecurityError' : null,
+ register_method(script, {scope: scope}),
'Registering same scope as the script directory without the last ' +
'slash should fail with SecurityError.');
}, 'Registering same scope as the script directory without the last slash');
@@ -67,9 +67,9 @@ function registration_tests(register_method, check_error_types) {
promise_test(function(t) {
var script = 'resources/registration-worker.js';
var scope = 'different-directory/';
- return assert_promise_rejects(
- register_method(script, {scope: scope}),
+ return promise_rejects(t,
check_error_types ? 'SecurityError' : null,
+ register_method(script, {scope: scope}),
'Registration scope outside the script directory should fail ' +
'with SecurityError.');
}, 'Registration scope outside the script directory');
@@ -77,27 +77,27 @@ function registration_tests(register_method, check_error_types) {
promise_test(function(t) {
var script = 'resources/registration-worker.js';
var scope = 'http://example.com/';
- return assert_promise_rejects(
- register_method(script, {scope: scope}),
+ return promise_rejects(t,
check_error_types ? 'SecurityError' : null,
+ register_method(script, {scope: scope}),
'Registration scope outside domain should fail with SecurityError.');
}, 'Registering scope outside domain');
promise_test(function(t) {
var script = 'http://example.com/worker.js';
var scope = 'http://example.com/scope/';
- return assert_promise_rejects(
- register_method(script, {scope: scope}),
+ return promise_rejects(t,
check_error_types ? 'SecurityError' : null,
+ register_method(script, {scope: scope}),
'Registration script outside domain should fail with SecurityError.');
}, 'Registering script outside domain');
promise_test(function(t) {
var script = 'resources/no-such-worker.js';
var scope = 'resources/scope/no-such-worker';
- return assert_promise_rejects(
- register_method(script, {scope: scope}),
+ return promise_rejects(t,
check_error_types ? 'NetworkError' : null,
+ register_method(script, {scope: scope}),
navigator.serviceWorker.register(script, {scope: scope}),
'Registration of non-existent script should fail.');
}, 'Registering non-existent script');
@@ -105,36 +105,36 @@ function registration_tests(register_method, check_error_types) {
promise_test(function(t) {
var script = 'resources/invalid-chunked-encoding.php';
var scope = 'resources/scope/invalid-chunked-encoding/';
- return assert_promise_rejects(
- register_method(script, {scope: scope}),
+ return promise_rejects(t,
check_error_types ? 'NetworkError' : null,
+ register_method(script, {scope: scope}),
'Registration of invalid chunked encoding script should fail.');
}, '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 assert_promise_rejects(
- register_method(script, {scope: scope}),
+ return promise_rejects(t,
check_error_types ? 'NetworkError' : null,
+ register_method(script, {scope: scope}),
'Registration of invalid chunked encoding script should fail.');
}, 'Registering invalid chunked encoding script with flush');
promise_test(function(t) {
var script = 'resources/mime-type-worker.php';
var scope = 'resources/scope/no-mime-type-worker/';
- return assert_promise_rejects(
- register_method(script, {scope: scope}),
+ return promise_rejects(t,
check_error_types ? 'SecurityError' : null,
+ register_method(script, {scope: scope}),
'Registration of no MIME type script should fail.');
}, 'Registering script with no MIME type');
promise_test(function(t) {
var script = 'resources/mime-type-worker.php?mime=text/plain';
var scope = 'resources/scope/bad-mime-type-worker/';
- return assert_promise_rejects(
- register_method(script, {scope: scope}),
+ return promise_rejects(t,
check_error_types ? 'SecurityError' : null,
+ register_method(script, {scope: scope}),
'Registration of plain text script should fail.');
}, 'Registering script with bad MIME type');
@@ -142,36 +142,36 @@ function registration_tests(register_method, check_error_types) {
var script = 'resources/redirect.php?Redirect=' +
encodeURIComponent('/resources/registration-worker.js');
var scope = 'resources/scope/redirect/';
- return assert_promise_rejects(
- register_method(script, {scope: scope}),
+ return promise_rejects(t,
check_error_types ? 'SecurityError' : null,
+ register_method(script, {scope: scope}),
'Registration of redirected script should fail.');
}, 'Registering redirected script');
promise_test(function(t) {
var script = 'resources/malformed-worker.php?parse-error';
var scope = 'resources/scope/parse-error';
- return assert_promise_rejects(
- register_method(script, {scope: scope}),
+ return promise_rejects(t,
check_error_types ? 'AbortError' : null,
+ register_method(script, {scope: scope}),
'Registration of script including parse error should fail.');
}, 'Registering script including parse error');
promise_test(function(t) {
var script = 'resources/malformed-worker.php?undefined-error';
var scope = 'resources/scope/undefined-error';
- return assert_promise_rejects(
- register_method(script, {scope: scope}),
+ return promise_rejects(t,
check_error_types ? 'AbortError' : null,
+ register_method(script, {scope: scope}),
'Registration of script including undefined error should fail.');
}, 'Registering script including undefined error');
promise_test(function(t) {
var script = 'resources/malformed-worker.php?uncaught-exception';
var scope = 'resources/scope/uncaught-exception';
- return assert_promise_rejects(
- register_method(script, {scope: scope}),
+ return promise_rejects(t,
check_error_types ? 'AbortError' : null,
+ register_method(script, {scope: scope}),
'Registration of script including uncaught exception should fail.');
}, 'Registering script including uncaught exception');
@@ -190,18 +190,18 @@ function registration_tests(register_method, check_error_types) {
promise_test(function(t) {
var script = 'resources/malformed-worker.php?import-malformed-script';
var scope = 'resources/scope/import-malformed-script';
- return assert_promise_rejects(
- register_method(script, {scope: scope}),
+ return promise_rejects(t,
check_error_types ? 'AbortError' : null,
+ register_method(script, {scope: scope}),
'Registration of script importing malformed script should fail.');
}, '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 assert_promise_rejects(
- register_method(script, {scope: scope}),
+ return promise_rejects(t,
check_error_types ? 'AbortError' : null,
+ register_method(script, {scope: scope}),
'Registration of script importing non-existent script should fail.');
}, 'Registering script importing non-existent script');
@@ -238,54 +238,54 @@ function registration_tests(register_method, check_error_types) {
promise_test(function(t) {
var script = 'resources%2fempty-worker.js';
var scope = 'resources/scope/encoded-slash-in-script-url';
- return assert_promise_rejects(
- register_method(script, {scope: scope}),
+ return promise_rejects(t,
check_error_types ? new TypeError : null,
+ register_method(script, {scope: scope}),
'URL-encoded slash in the script URL should be rejected.');
}, 'Script URL including URL-encoded slash');
promise_test(function(t) {
var script = 'resources%2Fempty-worker.js';
var scope = 'resources/scope/encoded-slash-in-script-url';
- return assert_promise_rejects(
- register_method(script, {scope: scope}),
+ return promise_rejects(t,
check_error_types ? new TypeError : null,
+ register_method(script, {scope: scope}),
'URL-encoded slash in the script URL should be rejected.');
}, 'Script URL including uppercase URL-encoded slash');
promise_test(function(t) {
var script = 'resources/empty-worker.js';
var scope = 'resources/scope%2fencoded-slash-in-scope';
- return assert_promise_rejects(
- register_method(script, {scope: scope}),
+ return promise_rejects(t,
check_error_types ? new TypeError : null,
+ register_method(script, {scope: scope}),
'URL-encoded slash in the scope should be rejected.');
}, 'Scope including URL-encoded slash');
promise_test(function(t) {
var script = 'resources%5cempty-worker.js';
var scope = 'resources/scope/encoded-slash-in-script-url';
- return assert_promise_rejects(
- register_method(script, {scope: scope}),
+ return promise_rejects(t,
check_error_types ? new TypeError : null,
+ register_method(script, {scope: scope}),
'URL-encoded backslash in the script URL should be rejected.');
}, 'Script URL including URL-encoded backslash');
promise_test(function(t) {
var script = 'resources%5Cempty-worker.js';
var scope = 'resources/scope/encoded-slash-in-script-url';
- return assert_promise_rejects(
- register_method(script, {scope: scope}),
+ return promise_rejects(t,
check_error_types ? new TypeError : null,
+ register_method(script, {scope: scope}),
'URL-encoded backslash in the script URL should be rejected.');
}, 'Script URL including uppercase URL-encoded backslash');
promise_test(function(t) {
var script = 'resources/empty-worker.js';
var scope = 'resources/scope%5cencoded-slash-in-scope';
- return assert_promise_rejects(
- register_method(script, {scope: scope}),
+ return promise_rejects(t,
check_error_types ? new TypeError : null,
+ register_method(script, {scope: scope}),
'URL-encoded backslash in the scope should be rejected.');
}, 'Scope including URL-encoded backslash');
@@ -344,18 +344,18 @@ function registration_tests(register_method, check_error_types) {
promise_test(function(t) {
var script = 'resources/empty-worker.js';
var scope = 'resources/../scope/parent-reference-in-scope';
- return assert_promise_rejects(
- register_method(script, {scope: scope}),
+ return promise_rejects(t,
check_error_types ? 'SecurityError' : null,
+ register_method(script, {scope: scope}),
'Scope not under the script directory should be rejected.');
}, 'Scope including parent-reference and not under the script directory');
promise_test(function(t) {
var script = 'resources////empty-worker.js';
var scope = 'resources/scope/consecutive-slashes-in-script-url';
- return assert_promise_rejects(
- register_method(script, {scope: scope}),
+ return promise_rejects(t,
check_error_types ? 'SecurityError' : null,
+ register_method(script, {scope: scope}),
'Consecutive slashes in the script url should not be unified.');
}, 'Script URL including consecutive slashes');
@@ -378,9 +378,9 @@ function registration_tests(register_method, check_error_types) {
promise_test(function(t) {
var script = 'filesystem:' + normalizeURL('resources/empty-worker.js');
var scope = 'resources/scope/filesystem-script-url';
- return assert_promise_rejects(
- register_method(script, {scope: scope}),
+ return promise_rejects(t,
check_error_types ? 'SecurityError' : null,
+ register_method(script, {scope: scope}),
'Registering a script which has same-origin filesystem: URL should ' +
'fail with SecurityError.');
}, 'Script URL is same-origin filesystem: URL');
@@ -388,9 +388,9 @@ function registration_tests(register_method, check_error_types) {
promise_test(function(t) {
var script = 'resources/empty-worker.js';
var scope = 'filesystem:' + normalizeURL('resources/scope/filesystem-scope-url');
- return assert_promise_rejects(
- register_method(script, {scope: scope}),
+ return promise_rejects(t,
check_error_types ? 'SecurityError' : null,
+ register_method(script, {scope: scope}),
'Registering with the scope that has same-origin filesystem: URL ' +
'should fail with SecurityError.');
}, 'Scope URL is same-origin filesystem: URL');

Powered by Google App Engine
This is Rietveld 408576698