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

Unified Diff: third_party/WebKit/LayoutTests/external/wpt/service-workers/service-worker/resources/clients-get-cross-origin-frame.html

Issue 2778903002: Upstream service worker `client` tests to WPT (Closed)
Patch Set: Streamline Created 3 years, 9 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/external/wpt/service-workers/service-worker/resources/clients-get-cross-origin-frame.html
diff --git a/third_party/WebKit/LayoutTests/http/tests/serviceworker/resources/clients-get-cross-origin-frame.html b/third_party/WebKit/LayoutTests/external/wpt/service-workers/service-worker/resources/clients-get-cross-origin-frame.html
similarity index 70%
rename from third_party/WebKit/LayoutTests/http/tests/serviceworker/resources/clients-get-cross-origin-frame.html
rename to third_party/WebKit/LayoutTests/external/wpt/service-workers/service-worker/resources/clients-get-cross-origin-frame.html
index 0977600366e63709f87a2d69c5fcf8a6304cb85f..e9c711d64f2c882ec52684257f871a50b8e91a4f 100644
--- a/third_party/WebKit/LayoutTests/http/tests/serviceworker/resources/clients-get-cross-origin-frame.html
+++ b/third_party/WebKit/LayoutTests/external/wpt/service-workers/service-worker/resources/clients-get-cross-origin-frame.html
@@ -1,8 +1,8 @@
<!DOCTYPE html>
-<script src="../../resources/testharness.js"></script>
-<script src="../../resources/testharnessreport.js"></script>
-<script src="../../resources/get-host-info.js"></script>
-<script src="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="test-helpers.sub.js"></script>
<script>
var host_info = get_host_info();
var scope = 'blank.html?clients-get';
@@ -29,14 +29,13 @@ var wait_for_worker_promise = navigator.serviceWorker.getRegistration(scope)
});
});
-function send_result(result) {
+function getEventOrigin(e) {
falken 2017/03/29 01:43:58 I believe WPT style is mostly to use snake_case, b
mike3 2017/03/29 15:15:23 Got it. Since `getEventOrigin` is out-of-scope, I'
window.parent.postMessage(
- {result: result},
- host_info['HTTP_ORIGIN']);
+ { type: 'eventOrigin', value: e.origin }, host_info['HTTPS_ORIGIN']
+ );
}
-window.addEventListener('message', function(e) {
- assert_equals(e.origin, host_info['HTTP_ORIGIN']);
+function getClientId(e) {
var cross_origin_client_ids = [];
cross_origin_client_ids.push(e.data.clientId);
wait_for_worker_promise
@@ -48,11 +47,21 @@ window.addEventListener('message', function(e) {
var channel = new MessageChannel();
channel.port1.onmessage = function(e) {
registration.unregister();
- send_result(e.data);
+ window.parent.postMessage(
+ { type: 'clientId', value: e.data }, host_info['HTTPS_ORIGIN']
+ );
};
iframe.contentWindow.navigator.serviceWorker.controller.postMessage(
{port:channel.port2, clientIds: cross_origin_client_ids},
[channel.port2]);
});
+}
+
+window.addEventListener('message', function(e) {
+ if (e.data.type === 'getEventOrigin') {
+ getEventOrigin(e);
+ } else if (e.data.type === 'getClientId') {
+ getClientId(e);
+ }
});
</script>

Powered by Google App Engine
This is Rietveld 408576698