Bug 1311247 - Avoid using unsafe CPOWs in browser_perwindow_privateBrowsing.js; r=mrbkap

This commit is contained in:
Ehsan Akhgari 2016-10-18 22:55:12 -04:00
Родитель 9512e2b48d
Коммит 5caff82499
4 изменённых файлов: 19 добавлений и 16 удалений

Просмотреть файл

@ -19,7 +19,7 @@
let event = yield undefined; let event = yield undefined;
if (event.type == "success") { if (event.type == "success") {
testResult = event.target.result; testResult = event.target.result instanceof IDBDatabase;
} }
else { else {
testException = event.target.error.name; testException = event.target.error.name;

Просмотреть файл

@ -24,8 +24,8 @@ function test1()
gBrowser.selectedBrowser.addEventListener("load", function () { gBrowser.selectedBrowser.addEventListener("load", function () {
gBrowser.selectedBrowser.removeEventListener("load", arguments.callee, true); gBrowser.selectedBrowser.removeEventListener("load", arguments.callee, true);
setFinishedCallback(function(result, exception) { setFinishedCallback(function(isIDBDatabase, exception) {
ok(result instanceof IDBDatabase, ok(isIDBDatabase,
"First database creation was successful"); "First database creation was successful");
ok(!exception, "No exception"); ok(!exception, "No exception");
is(getPermission(testPageURL, "indexedDB"), is(getPermission(testPageURL, "indexedDB"),
@ -60,8 +60,8 @@ function test2()
gBrowser.selectedBrowser.addEventListener("load", function () { gBrowser.selectedBrowser.addEventListener("load", function () {
gBrowser.selectedBrowser.removeEventListener("load", arguments.callee, true); gBrowser.selectedBrowser.removeEventListener("load", arguments.callee, true);
setFinishedCallback(function(result, exception) { setFinishedCallback(function(isIDBDatabase, exception) {
ok(result instanceof IDBDatabase, ok(isIDBDatabase,
"First database creation was successful"); "First database creation was successful");
ok(!exception, "No exception"); ok(!exception, "No exception");
is(getPermission(testPageURL, "indexedDB"), is(getPermission(testPageURL, "indexedDB"),

Просмотреть файл

@ -25,8 +25,8 @@ function test1()
} }
gBrowser.selectedBrowser.removeEventListener("load", arguments.callee, true); gBrowser.selectedBrowser.removeEventListener("load", arguments.callee, true);
setFinishedCallback(function(result, exception) { setFinishedCallback(function(isIDBDatabase, exception) {
ok(result instanceof IDBDatabase, ok(isIDBDatabase,
"First database creation was successful"); "First database creation was successful");
ok(!exception, "No exception"); ok(!exception, "No exception");
gBrowser.removeCurrentTab(); gBrowser.removeCurrentTab();
@ -57,8 +57,8 @@ function test3(win)
} }
win.gBrowser.selectedBrowser.removeEventListener("load", arguments.callee, true); win.gBrowser.selectedBrowser.removeEventListener("load", arguments.callee, true);
setFinishedCallback(function(result, exception) { setFinishedCallback(function(isIDBDatabase, exception) {
ok(!result, "No database"); ok(!isIDBDatabase, "No database");
is(exception, "InvalidStateError", "Correct exception"); is(exception, "InvalidStateError", "Correct exception");
win.gBrowser.removeCurrentTab(); win.gBrowser.removeCurrentTab();

Просмотреть файл

@ -92,13 +92,16 @@ function setFinishedCallback(callback, win)
if (!win) { if (!win) {
win = window; win = window;
} }
let testPage = win.gBrowser.selectedBrowser.contentWindow.wrappedJSObject; ContentTask.spawn(win.gBrowser.selectedBrowser, null, function*() {
testPage.testFinishedCallback = function(result, exception) { return yield new Promise(resolve => {
setTimeout(function() { content.wrappedJSObject.testFinishedCallback = (result, exception) => {
info("got finished callback"); info("got finished callback");
callback(result, exception); resolve({result, exception});
}, 0); };
} });
}).then(({result, exception}) => {
callback(result, exception);
});
} }
function dispatchEvent(eventName) function dispatchEvent(eventName)