Skip to content

Instantly share code, notes, and snippets.

@jugglinmike
Created May 16, 2017 16:55
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/e8eb9efdbb8e32210def383760f8a2c9 to your computer and use it in GitHub Desktop.
Save jugglinmike/e8eb9efdbb8e32210def383760f8a2c9 to your computer and use it in GitHub Desktop.
sw-migration-referer
diff --git a/third_party/WebKit/LayoutTests/http/tests/serviceworker/resources/referer-iframe.html b/third_party/WebKit/LayoutTests/external/wpt/service-workers/service-worker/resources/referer-iframe.html
index 071e084..295ff45 100644
--- a/third_party/WebKit/LayoutTests/http/tests/serviceworker/resources/referer-iframe.html
+++ b/third_party/WebKit/LayoutTests/external/wpt/service-workers/service-worker/resources/referer-iframe.html
@@ -1,15 +1,16 @@
-<script src="../../resources/get-host-info.js"></script>
+<script src="/common/get-host-info.sub.js"></script>
+<script src="test-helpers.sub.js"></script>
<script>
function check_referer(url, expected_referer) {
return fetch(url)
.then(function(res) { return res.json(); })
.then(function(headers) {
- if (headers['Referer'] === expected_referer) {
+ if (headers['referer'] === expected_referer) {
return Promise.resolve();
} else {
return Promise.reject('Referer for ' + url + ' must be ' +
expected_referer + ' but got ' +
- headers['Referer']);
+ headers['referer']);
}
});
}
@@ -17,20 +18,20 @@ function check_referer(url, expected_referer) {
window.addEventListener('message', function(evt) {
var host_info = get_host_info();
var port = evt.ports[0];
- check_referer('request-headers.php?ignore=true',
- host_info['HTTP_ORIGIN'] +
- '/serviceworker/resources/referer-iframe.html')
+ check_referer('request-headers.py?ignore=true',
+ host_info['HTTPS_ORIGIN'] +
+ base_path() + 'referer-iframe.html')
.then(function() {
return check_referer(
- 'request-headers.php',
- host_info['HTTP_ORIGIN'] +
- '/serviceworker/resources/referer-iframe.html');
+ 'request-headers.py',
+ host_info['HTTPS_ORIGIN'] +
+ base_path() + 'referer-iframe.html');
})
.then(function() {
return check_referer(
- 'request-headers.php?url=request-headers.php',
- host_info['HTTP_ORIGIN'] +
- '/serviceworker/resources/fetch-rewrite-worker.js');
+ 'request-headers.py?url=request-headers.py',
+ host_info['HTTPS_ORIGIN'] +
+ base_path() + 'fetch-rewrite-worker.js');
})
.then(function() { port.postMessage({results: 'finish'}); })
.catch(function(e) { port.postMessage({results: 'failure:' + e}); });
diff --git a/third_party/WebKit/LayoutTests/http/tests/serviceworker/referer.html b/third_party/WebKit/LayoutTests/external/wpt/service-workers/service-worker/referer.https.html
index 8b9105a..43fccba 100644
--- a/third_party/WebKit/LayoutTests/http/tests/serviceworker/referer.html
+++ b/third_party/WebKit/LayoutTests/external/wpt/service-workers/service-worker/referer.https.html
@@ -1,9 +1,9 @@
<!DOCTYPE html>
<title>Service Worker: check referer of fetch()</title>
-<script src="../resources/testharness.js"></script>
-<script src="../resources/testharnessreport.js"></script>
-<script src="../resources/get-host-info.js?pipe=sub"></script>
-<script src="resources/test-helpers.js"></script>
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<script src="/common/get-host-info.sub.js"></script>
+<script src="resources/test-helpers.sub.js?pipe=sub"></script>
<script>
async_test(function(t) {
var SCOPE = 'resources/referer-iframe.html';
@@ -22,7 +22,7 @@ async_test(function(t) {
service_worker_unregister_and_done(t, SCOPE);
});
frame.contentWindow.postMessage({},
- host_info['HTTP_ORIGIN'],
+ host_info['HTTPS_ORIGIN'],
[channel.port2]);
})
.catch(unreached_rejection(t));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment