Skip to content

Commit 417de17

Browse files
authored
Add optional ?timeout parameter to Storage Blocking test page (#406)
The Storage Blocking test page loads several iframes, and considers them to have failed to load after a one second timeout. That was causing some of our browser extension integration tests to fail sometimes, when the iframes take longer to load. Add an optional ?timeout parameter, which can be used to increase the iframe loading timeout when necessary.
1 parent 598bdc9 commit 417de17

File tree

1 file changed

+9
-6
lines changed
  • privacy-protections/storage-blocking

1 file changed

+9
-6
lines changed

privacy-protections/storage-blocking/main.js

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
/* globals commonTests,THIRD_PARTY_ORIGIN,THIRD_PARTY_TRACKER_ORIGIN,THIRD_PARTY_AD_ORIGIN,cookieStore */
22

3+
const { searchParams } = new URL(window.location);
4+
const iframeLoadTimeoutMs = parseInt(searchParams.get('timeout'), 10) || 1000;
5+
36
const storeButton = document.querySelector('#store');
47
const retriveButton = document.querySelector('#retrive');
58
const downloadButton = document.querySelector('#download');
@@ -40,7 +43,7 @@ function create3pIframeTest (name, origin) {
4043

4144
window.addEventListener('message', cleanUp);
4245
iframe.addEventListener('load', () => {
43-
failTimeout = setTimeout(() => rej('timeout'), 1000);
46+
failTimeout = setTimeout(() => rej('timeout'), iframeLoadTimeoutMs);
4447
});
4548

4649
document.body.appendChild(iframe);
@@ -69,7 +72,7 @@ function create3pIframeTest (name, origin) {
6972

7073
window.addEventListener('message', cleanUp);
7174
iframe.addEventListener('load', () => {
72-
failTimeout = setTimeout(() => rej('timeout'), 1000);
75+
failTimeout = setTimeout(() => rej('timeout'), iframeLoadTimeoutMs);
7376
});
7477

7578
document.body.appendChild(iframe);
@@ -332,11 +335,11 @@ downloadButton.addEventListener('click', () => downloadTheResults());
332335
storeButton.addEventListener('click', () => storeData());
333336
retriveButton.addEventListener('click', () => retrieveData());
334337

335-
// if url query is '?store' store the data immadiatelly
336-
if (document.location.search === '?store') {
338+
// If URL contains 'store' parameter, store the data immediately.
339+
if (searchParams.has('store')) {
337340
storeData();
338341
}
339-
// if url query is '?retrive' retrieve the data immadiatelly
340-
if (document.location.search === '?retrive') {
342+
// If URL contains 'retrive' parameter, retrieve the data immediately.
343+
if (searchParams.has('retrive')) {
341344
retrieveData();
342345
}

0 commit comments

Comments
 (0)