Skip to content

Commit

Permalink
Bug 1492127 - Split browser_blockingIndexedDb.js into browser_blockin…
Browse files Browse the repository at this point in the history
…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
ehsan committed Oct 10, 2018
1 parent 23e167e commit f182b82
Show file tree
Hide file tree
Showing 3 changed files with 173 additions and 173 deletions.
1 change: 1 addition & 0 deletions toolkit/components/antitracking/test/browser/browser.ini
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ support-files = server.sjs
[browser_blockingDOMCache.js]
skip-if = (os == "win" && os_version == "6.1" && bits == 32 && !debug) # Bug 1491937
[browser_blockingIndexedDb.js]
[browser_blockingIndexedDbInWorkers.js]
[browser_blockingLocalStorage.js]
skip-if = serviceworker_e10s
[browser_blockingSessionStorage.js]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,67 +21,6 @@ AntiTracking.runTest("IndexedDB",
});
});

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 and Storage Access API",
// blocking callback
async _ => {
Expand Down Expand Up @@ -123,115 +62,3 @@ AntiTracking.runTest("IndexedDB and Storage Access API",
});
},
null, false, false);

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);
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);

0 comments on commit f182b82

Please sign in to comment.