Skip to content

Instantly share code, notes, and snippets.

@jugglinmike
Created May 11, 2017 16:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jugglinmike/42f92cce3c3d77cc016acedcc3ae43ed to your computer and use it in GitHub Desktop.
Save jugglinmike/42f92cce3c3d77cc016acedcc3ae43ed to your computer and use it in GitHub Desktop.
sw-migration-opaque-response.diff
diff --git a/third_party/WebKit/LayoutTests/http/tests/serviceworker/opaque-response-in-memorycache.html b/third_party/WebKit/LayoutTests/external/wpt/service-workers/service-worker/opaque-response-preloaded.https.html
similarity index 72%
rename from third_party/WebKit/LayoutTests/http/tests/serviceworker/opaque-response-in-memorycache.html
rename to third_party/WebKit/LayoutTests/external/wpt/service-workers/service-worker/opaque-response-preloaded.https.html
index a723e24..16fbb9a 100644
--- a/third_party/WebKit/LayoutTests/http/tests/serviceworker/opaque-response-in-memorycache.html
+++ b/third_party/WebKit/LayoutTests/external/wpt/service-workers/service-worker/opaque-response-preloaded.https.html
@@ -1,14 +1,14 @@
<!DOCTYPE html>
<meta charset="utf-8">
-<title>Opaque responses on MemoryCache should not be reused for XHRs</title>
+<title>Opaque responses should not be reused for XHRs</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
-<script src="resources/test-helpers.js"></script>
+<script src="resources/test-helpers.sub.js"></script>
<script>
const WORKER =
- 'resources/opaque-response-in-memorycache-worker.js';
+ 'resources/opaque-response-preloaded-worker.js';
const SCOPE =
- 'resources/opaque-response-in-memorycache-iframe.html';
+ 'resources/opaque-response-preloaded-iframe.html';
var resolve_done;
var done_was_called = new Promise(resolve => resolve_done = resolve);
// Called by the iframe when done.
@@ -24,7 +24,8 @@ promise_test(t => {
return wait_for_state(t, reg.installing, 'activated');
})
.then(() => with_iframe(SCOPE))
+ .then(frame => t.add_cleanup(() => frame.remove() ))
.then(() => done_was_called)
.then(result => assert_equals(result, 'PASS'));
- }, 'Opaque responses on MemoryCache should not be reused for XHRs');
+ }, 'Opaque responses should not be reused for XHRs');
</script>
diff --git a/third_party/WebKit/LayoutTests/http/tests/serviceworker/resources/opaque-response-in-memorycache-iframe.html b/third_party/WebKit/LayoutTests/external/wpt/service-workers/service-worker/resources/opaque-response-preloaded-iframe.html
similarity index 89%
rename from third_party/WebKit/LayoutTests/http/tests/serviceworker/resources/opaque-response-in-memorycache-iframe.html
rename to third_party/WebKit/LayoutTests/external/wpt/service-workers/service-worker/resources/opaque-response-preloaded-iframe.html
index 5214b91..6241144 100644
--- a/third_party/WebKit/LayoutTests/http/tests/serviceworker/resources/opaque-response-in-memorycache-iframe.html
+++ b/third_party/WebKit/LayoutTests/external/wpt/service-workers/service-worker/resources/opaque-response-preloaded-iframe.html
@@ -12,8 +12,7 @@ function runTest() {
xhr.open('GET', 'opaque-response');
// opaque-response returns an opaque response from serviceworker and thus
// the XHR must fail because it is not no-cors request.
- // Particularly, the XHR must not reuse preloaded the opaque response on
- // MemoryCache.
+ // Particularly, the XHR must not reuse the preloaded the opaque response.
xhr.onerror = function() {
parent.done('PASS');
};
diff --git a/third_party/WebKit/LayoutTests/http/tests/serviceworker/resources/opaque-response-in-memorycache-worker.js b/third_party/WebKit/LayoutTests/external/wpt/service-workers/service-worker/resources/opaque-response-preloaded-worker.js
similarity index 17%
rename from third_party/WebKit/LayoutTests/http/tests/serviceworker/resources/opaque-response-in-memorycache-worker.js
rename to third_party/WebKit/LayoutTests/external/wpt/service-workers/service-worker/resources/opaque-response-preloaded-worker.js
index 2a58d8c..1615be2 100644
--- a/third_party/WebKit/LayoutTests/http/tests/serviceworker/resources/opaque-response-in-memorycache-worker.js
+++ b/third_party/WebKit/LayoutTests/external/wpt/service-workers/service-worker/resources/opaque-response-preloaded-worker.js
@@ -1,5 +1,12 @@
+importScripts('/common/get-host-info.sub.js');
+
+var remoteUrl = get_host_info()['HTTPS_REMOTE_ORIGIN'] +
+ '/service-workers/service-worker/resources/simple.txt'
+
self.addEventListener('fetch', event => {
- if (!event.request.url.match(/opaque-response$/))
+ if (!event.request.url.match(/opaque-response$/)) {
return;
- event.respondWith(fetch("http://localhost:8000/serviceworker/resources/simple.txt", {mode: 'no-cors'}));
+ }
+
+ event.respondWith(fetch(remoteUrl, {mode: 'no-cors'}));
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment