summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/client-hints/service-workers/resources/util.js
diff options
context:
space:
mode:
Diffstat (limited to 'testing/web-platform/tests/client-hints/service-workers/resources/util.js')
-rw-r--r--testing/web-platform/tests/client-hints/service-workers/resources/util.js23
1 files changed, 23 insertions, 0 deletions
diff --git a/testing/web-platform/tests/client-hints/service-workers/resources/util.js b/testing/web-platform/tests/client-hints/service-workers/resources/util.js
new file mode 100644
index 0000000000..d9b8f3f4d9
--- /dev/null
+++ b/testing/web-platform/tests/client-hints/service-workers/resources/util.js
@@ -0,0 +1,23 @@
+async function ch_sw_test(t, worker, url, response) {
+ r = await service_worker_unregister_and_register(t, worker, url);
+ await wait_for_state(t, r.installing, 'activated')
+ var popup_window = window.open("/common/blank.html");
+ assert_not_equals(popup_window, null, "Popup windows not allowed?");
+
+ t.add_cleanup(async _=>{
+ popup_window.close();
+ await r.unregister();
+ });
+
+ popup_load = new Promise((resolve, reject) => {
+ popup_window.addEventListener('load', t.step_func((e) => {
+ if(popup_window.location.pathname != "/blank.html") {
+ assert_equals(popup_window.document.body.textContent, response);
+ resolve();
+ }
+ }))
+ });
+
+ popup_window.location = url;
+ await popup_load;
+}