forked from mozilla/gecko-dev
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Bug 1492127 - Split browser_blockingIndexedDb.js into browser_blockin…
…gIndexedDb.js and browser_blockingIndexedDbInWorkers.js to give it more breathing room timeout-wise r=baku Depends on D8175 Differential Revision: https://phabricator.services.mozilla.com/D8176 --HG-- rename : toolkit/components/antitracking/test/browser/browser_blockingIndexedDb.js => toolkit/components/antitracking/test/browser/browser_blockingIndexedDbInWorkers.js extra : moz-landing-system : lando
- Loading branch information
Showing
3 changed files
with
173 additions
and
173 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
172 changes: 172 additions & 0 deletions
172
toolkit/components/antitracking/test/browser/browser_blockingIndexedDbInWorkers.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,172 @@ | ||
AntiTracking.runTest("IndexedDB in workers", | ||
async _ => { | ||
function blockCode() { | ||
try { | ||
indexedDB.open("test", "1"); | ||
postMessage(false); | ||
} catch (e) { | ||
postMessage(e.name == "SecurityError"); | ||
} | ||
} | ||
|
||
let blob = new Blob([blockCode.toString() + "; blockCode();"]); | ||
ok(blob, "Blob has been created"); | ||
|
||
let blobURL = URL.createObjectURL(blob); | ||
ok(blobURL, "Blob URL has been created"); | ||
|
||
let worker = new Worker(blobURL); | ||
ok(worker, "Worker has been created"); | ||
|
||
await new Promise((resolve, reject) => { | ||
worker.onmessage = function(e) { | ||
if (e) { | ||
resolve(); | ||
} else { | ||
reject(); | ||
} | ||
}; | ||
}); | ||
}, | ||
async _ => { | ||
function nonBlockCode() { | ||
indexedDB.open("test", "1"); | ||
postMessage(true); | ||
} | ||
|
||
let blob = new Blob([nonBlockCode.toString() + "; nonBlockCode();"]); | ||
ok(blob, "Blob has been created"); | ||
|
||
let blobURL = URL.createObjectURL(blob); | ||
ok(blobURL, "Blob URL has been created"); | ||
|
||
let worker = new Worker(blobURL); | ||
ok(worker, "Worker has been created"); | ||
|
||
await new Promise((resolve, reject) => { | ||
worker.onmessage = function(e) { | ||
if (e) { | ||
resolve(); | ||
} else { | ||
reject(); | ||
} | ||
}; | ||
}); | ||
}, | ||
async _ => { | ||
await new Promise(resolve => { | ||
Services.clearData.deleteData(Ci.nsIClearDataService.CLEAR_ALL, value => resolve()); | ||
}); | ||
}); | ||
|
||
AntiTracking.runTest("IndexedDB in workers and Storage Access API", | ||
async _ => { | ||
function blockCode() { | ||
try { | ||
indexedDB.open("test", "1"); | ||
postMessage(false); | ||
} catch (e) { | ||
postMessage(e.name == "SecurityError"); | ||
} | ||
} | ||
function nonBlockCode() { | ||
indexedDB.open("test", "1"); | ||
postMessage(true); | ||
} | ||
|
||
/* import-globals-from storageAccessAPIHelpers.js */ | ||
await noStorageAccessInitially(); | ||
|
||
let blob = new Blob([blockCode.toString() + "; blockCode();"]); | ||
ok(blob, "Blob has been created"); | ||
|
||
let blobURL = URL.createObjectURL(blob); | ||
ok(blobURL, "Blob URL has been created"); | ||
|
||
let worker = new Worker(blobURL); | ||
ok(worker, "Worker has been created"); | ||
|
||
await new Promise((resolve, reject) => { | ||
worker.onmessage = function(e) { | ||
if (e) { | ||
resolve(); | ||
} else { | ||
reject(); | ||
} | ||
}; | ||
}); | ||
|
||
/* import-globals-from storageAccessAPIHelpers.js */ | ||
await callRequestStorageAccess(); | ||
|
||
blob = new Blob([nonBlockCode.toString() + "; nonBlockCode();"]); | ||
ok(blob, "Blob has been created"); | ||
|
||
blobURL = URL.createObjectURL(blob); | ||
ok(blobURL, "Blob URL has been created"); | ||
|
||
worker = new Worker(blobURL); | ||
ok(worker, "Worker has been created"); | ||
|
||
await new Promise((resolve, reject) => { | ||
worker.onmessage = function(e) { | ||
if (e) { | ||
resolve(); | ||
} else { | ||
reject(); | ||
} | ||
}; | ||
}); | ||
}, | ||
async _ => { | ||
function nonBlockCode() { | ||
indexedDB.open("test", "1"); | ||
postMessage(true); | ||
} | ||
|
||
/* import-globals-from storageAccessAPIHelpers.js */ | ||
await noStorageAccessInitially(); | ||
|
||
let blob = new Blob([nonBlockCode.toString() + "; nonBlockCode();"]); | ||
ok(blob, "Blob has been created"); | ||
|
||
let blobURL = URL.createObjectURL(blob); | ||
ok(blobURL, "Blob URL has been created"); | ||
|
||
let worker = new Worker(blobURL); | ||
ok(worker, "Worker has been created"); | ||
|
||
await new Promise((resolve, reject) => { | ||
worker.onmessage = function(e) { | ||
if (e) { | ||
resolve(); | ||
} else { | ||
reject(); | ||
} | ||
}; | ||
}); | ||
|
||
/* import-globals-from storageAccessAPIHelpers.js */ | ||
await callRequestStorageAccess(); | ||
|
||
// For non-tracking windows, calling the API is a no-op | ||
|
||
worker = new Worker(blobURL); | ||
ok(worker, "Worker has been created"); | ||
|
||
await new Promise((resolve, reject) => { | ||
worker.onmessage = function(e) { | ||
if (e) { | ||
resolve(); | ||
} else { | ||
reject(); | ||
} | ||
}; | ||
}); | ||
}, | ||
async _ => { | ||
await new Promise(resolve => { | ||
Services.clearData.deleteData(Ci.nsIClearDataService.CLEAR_ALL, value => resolve()); | ||
}); | ||
}, | ||
null, false, false); |