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

Unified Diff: third_party/WebKit/LayoutTests/http/tests/serviceworker/resources/register-foreign-fetch-errors-worker.js

Issue 1406823002: Start of foreign fetch implementation. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: remove blank line Created 5 years, 2 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/register-foreign-fetch-errors-worker.js
diff --git a/third_party/WebKit/LayoutTests/http/tests/serviceworker/resources/register-foreign-fetch-errors-worker.js b/third_party/WebKit/LayoutTests/http/tests/serviceworker/resources/register-foreign-fetch-errors-worker.js
new file mode 100644
index 0000000000000000000000000000000000000000..fcbb266fef4247d6438a04dd205c87e3503b285f
--- /dev/null
+++ b/third_party/WebKit/LayoutTests/http/tests/serviceworker/resources/register-foreign-fetch-errors-worker.js
@@ -0,0 +1,65 @@
+self.addEventListener('install', function(event) {
+ var scope = registration.scope;
+ var scope_url = new URL(scope);
+
+ test(function() {
+ assert_throws(new TypeError(), function() {
+ event.registerForeignFetchScopes(scope);
+ });
+ }, 'Not an array');
+
+ test(function() {
+ assert_throws(new TypeError(), function() {
+ event.registerForeignFetchScopes([{}]);
+ });
+ }, 'Not a string in array');
+
+ test(function() {
+ assert_throws(new TypeError(), function() {
+ event.registerForeignFetchScopes(['/foo']);
+ });
+ }, 'Relative url not under scope');
+
+ test(function() {
+ var url = new URL(scope_url);
+ url.host = 'example.com';
+ assert_throws(new TypeError(), function() {
+ event.registerForeignFetchScopes([url.href]);
+ });
+ }, 'Absolute url not under scope');
+
+ async_test(function(t) {
+ self.setTimeout(t.step_func(function() {
+ assert_throws('InvalidStateError', function() {
+ event.registerForeignFetchScopes([scope]);
+ });
+ t.done();
+ }), 1);
+ }, 'Call after event returned');
+
+ test(function() {
+ event.registerForeignFetchScopes([]);
+ }, 'Empty array');
+
+ test(function() {
+ event.registerForeignFetchScopes([scope, scope + '/foo']);
+ }, 'Absolute urls');
+
+ test(function() {
+ // Figure out scope relative to location of this script:
+ var local_dir = location.pathname;
+ local_dir = local_dir.substr(0, local_dir.lastIndexOf('/'));
+ assert_true(scope_url.pathname.startsWith(local_dir));
+ var relative_scope = scope_url.pathname.substr(local_dir.length + 1);
+
+ event.registerForeignFetchScopes([
+ scope_url.pathname,
+ relative_scope,
+ './' + relative_scope,
+ relative_scope + '/foo']);
+ }, 'Relative urls');
+ });
+
+// Import testharness after install handler to make sure our install handler
+// runs first. Otherwise only one test will run.
+importScripts('../../resources/testharness.js');

Powered by Google App Engine
This is Rietveld 408576698