Bug 1321215 - Remove legacy generator from browser/. r=Paolo

This commit is contained in:
Tooru Fujisawa 2017-01-21 22:52:44 +09:00
Родитель 3594725777
Коммит 82e73ed5ac
38 изменённых файлов: 278 добавлений и 307 удалений

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

@ -16,42 +16,38 @@
const Cu = Components.utils; const Cu = Components.utils;
Cu.import("resource://gre/modules/Services.jsm"); Cu.import("resource://gre/modules/Services.jsm");
Cu.import("resource://gre/modules/Task.jsm");
Cu.import("resource://gre/modules/Promise.jsm");
Cu.import("resource://gre/modules/XPCOMUtils.jsm"); Cu.import("resource://gre/modules/XPCOMUtils.jsm");
SimpleTest.waitForExplicitFinish(); SimpleTest.waitForExplicitFinish();
// Load error pages do not fire "load" events, so let's use a progressListener. // Load error pages do not fire "load" events, so let's use a progressListener.
function waitForErrorPage(frame) { function waitForErrorPage(frame) {
let errorPageDeferred = Promise.defer(); return new Promise(resolve => {
let progressListener = {
onLocationChange: function(aWebProgress, aRequest, aLocation, aFlags) {
if (aFlags & Ci.nsIWebProgressListener.LOCATION_CHANGE_ERROR_PAGE) {
frame.docShell.QueryInterface(Ci.nsIInterfaceRequestor)
.getInterface(Ci.nsIWebProgress)
.removeProgressListener(progressListener,
Ci.nsIWebProgress.NOTIFY_LOCATION);
let progressListener = { resolve();
onLocationChange: function(aWebProgress, aRequest, aLocation, aFlags) { }
if (aFlags & Ci.nsIWebProgressListener.LOCATION_CHANGE_ERROR_PAGE) { },
frame.docShell.QueryInterface(Ci.nsIInterfaceRequestor)
.getInterface(Ci.nsIWebProgress)
.removeProgressListener(progressListener,
Ci.nsIWebProgress.NOTIFY_LOCATION);
errorPageDeferred.resolve(); QueryInterface: XPCOMUtils.generateQI([Ci.nsIWebProgressListener,
} Ci.nsISupportsWeakReference])
}, };
QueryInterface: XPCOMUtils.generateQI([Ci.nsIWebProgressListener, frame.docShell.QueryInterface(Ci.nsIInterfaceRequestor)
Ci.nsISupportsWeakReference]) .getInterface(Ci.nsIWebProgress)
}; .addProgressListener(progressListener,
Ci.nsIWebProgress.NOTIFY_LOCATION);
frame.docShell.QueryInterface(Ci.nsIInterfaceRequestor) });
.getInterface(Ci.nsIWebProgress)
.addProgressListener(progressListener,
Ci.nsIWebProgress.NOTIFY_LOCATION);
return errorPageDeferred.promise;
} }
function doTest() { function doTest() {
Task.spawn(function test_aboutCrashed() { (async function testBody() {
let frame1 = document.getElementById("frame1"); let frame1 = document.getElementById("frame1");
let frame2 = document.getElementById("frame2"); let frame2 = document.getElementById("frame2");
let uri1 = Services.io.newURI("http://www.example.com/1", null, null); let uri1 = Services.io.newURI("http://www.example.com/1", null, null);
@ -61,7 +57,7 @@
frame1.docShell.chromeEventHandler.setAttribute("crashedPageTitle", "pageTitle"); frame1.docShell.chromeEventHandler.setAttribute("crashedPageTitle", "pageTitle");
frame1.docShell.displayLoadError(Components.results.NS_ERROR_CONTENT_CRASHED, uri1, null); frame1.docShell.displayLoadError(Components.results.NS_ERROR_CONTENT_CRASHED, uri1, null);
yield errorPageReady; await errorPageReady;
frame1.docShell.chromeEventHandler.removeAttribute("crashedPageTitle"); frame1.docShell.chromeEventHandler.removeAttribute("crashedPageTitle");
SimpleTest.is(frame1.contentDocument.documentURI, SimpleTest.is(frame1.contentDocument.documentURI,
@ -71,14 +67,14 @@
errorPageReady = waitForErrorPage(frame2); errorPageReady = waitForErrorPage(frame2);
frame2.docShell.displayLoadError(Components.results.NS_ERROR_CONTENT_CRASHED, uri2, null); frame2.docShell.displayLoadError(Components.results.NS_ERROR_CONTENT_CRASHED, uri2, null);
yield errorPageReady; await errorPageReady;
SimpleTest.is(frame2.contentDocument.documentURI, SimpleTest.is(frame2.contentDocument.documentURI,
"about:tabcrashed?e=tabcrashed&u=http%3A//www.example.com/2&c=UTF-8&f=regular&d=%20", "about:tabcrashed?e=tabcrashed&u=http%3A//www.example.com/2&c=UTF-8&f=regular&d=%20",
"Correct about:tabcrashed displayed for page with no title."); "Correct about:tabcrashed displayed for page with no title.");
SimpleTest.finish(); SimpleTest.finish();
}); })().catch(ex => SimpleTest.ok(false, ex));
} }
]]></script> ]]></script>

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

@ -17,17 +17,17 @@ add_task(function* test_indicatorDrop() {
let EventUtils = {}; let EventUtils = {};
scriptLoader.loadSubScript("chrome://mochikit/content/tests/SimpleTest/EventUtils.js", EventUtils); scriptLoader.loadSubScript("chrome://mochikit/content/tests/SimpleTest/EventUtils.js", EventUtils);
function task_drop(win, urls) { async function drop(win, urls) {
let dragData = [[{type: "text/plain", data: urls.join("\n")}]]; let dragData = [[{type: "text/plain", data: urls.join("\n")}]];
let listBox = win.document.getElementById("downloadsRichListBox"); let listBox = win.document.getElementById("downloadsRichListBox");
ok(listBox, "download list box present"); ok(listBox, "download list box present");
let list = yield Downloads.getList(Downloads.ALL); let list = await Downloads.getList(Downloads.ALL);
let added = new Set(); let added = new Set();
let succeeded = new Set(); let succeeded = new Set();
yield new Promise(function(resolve) { await new Promise(resolve => {
let view = { let view = {
onDownloadAdded: function(download) { onDownloadAdded: function(download) {
added.add(download.source.url); added.add(download.source.url);
@ -65,8 +65,8 @@ add_task(function* test_indicatorDrop() {
win.close(); win.close();
}); });
yield* task_drop(win, [httpUrl("file1.txt")]); yield drop(win, [httpUrl("file1.txt")]);
yield* task_drop(win, [httpUrl("file1.txt"), yield drop(win, [httpUrl("file1.txt"),
httpUrl("file2.txt"), httpUrl("file2.txt"),
httpUrl("file3.txt")]); httpUrl("file3.txt")]);
}); });

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

@ -7,8 +7,7 @@ var gTests;
function test() { function test() {
waitForExplicitFinish(); waitForExplicitFinish();
requestLongerTimeout(2); requestLongerTimeout(2);
gTests = runTest(); runTest().catch(ex => ok(false, ex));
gTests.next();
} }
/* /*
@ -17,34 +16,22 @@ function test() {
* ================ * ================
*/ */
function moveAlong(aResult) {
try {
gTests.send(aResult);
} catch (x if x instanceof StopIteration) {
finish();
}
}
function createWindow(aOptions) { function createWindow(aOptions) {
whenNewWindowLoaded(aOptions, function(win) { return new Promise(resolve => whenNewWindowLoaded(aOptions, resolve));
moveAlong(win);
});
} }
function getFile(downloadLastDir, aURI) { function getFile(downloadLastDir, aURI) {
downloadLastDir.getFileAsync(aURI, function(result) { return new Promise(resolve => downloadLastDir.getFileAsync(aURI, resolve));
moveAlong(result);
});
} }
function setFile(downloadLastDir, aURI, aValue) { function setFile(downloadLastDir, aURI, aValue) {
downloadLastDir.setFile(aURI, aValue); downloadLastDir.setFile(aURI, aValue);
executeSoon(moveAlong); return new Promise(resolve => executeSoon(resolve));
} }
function clearHistoryAndWait() { function clearHistoryAndWait() {
clearHistory(); clearHistory();
executeSoon(() => executeSoon(moveAlong)); return new Promise(resolve => executeSoon(_ => executeSoon(resolve)));
} }
/* /*
@ -53,7 +40,7 @@ function clearHistoryAndWait() {
* =================== * ===================
*/ */
function runTest() { async function runTest() {
let FileUtils = let FileUtils =
Cu.import("resource://gre/modules/FileUtils.jsm", {}).FileUtils; Cu.import("resource://gre/modules/FileUtils.jsm", {}).FileUtils;
let DownloadLastDir = let DownloadLastDir =
@ -81,12 +68,12 @@ function runTest() {
function checkDownloadLastDir(gDownloadLastDir, aLastDir) { function checkDownloadLastDir(gDownloadLastDir, aLastDir) {
is(gDownloadLastDir.file.path, aLastDir.path, is(gDownloadLastDir.file.path, aLastDir.path,
"gDownloadLastDir should point to the expected last directory"); "gDownloadLastDir should point to the expected last directory");
getFile(gDownloadLastDir, uri1); return getFile(gDownloadLastDir, uri1);
} }
function checkDownloadLastDirNull(gDownloadLastDir) { function checkDownloadLastDirNull(gDownloadLastDir) {
is(gDownloadLastDir.file, null, "gDownloadLastDir should be null"); is(gDownloadLastDir.file, null, "gDownloadLastDir should be null");
getFile(gDownloadLastDir, uri1); return getFile(gDownloadLastDir, uri1);
} }
/* /*
@ -95,8 +82,8 @@ function runTest() {
* ================================ * ================================
*/ */
let win = yield createWindow({private: false}); let win = await createWindow({private: false});
let pbWin = yield createWindow({private: true}); let pbWin = await createWindow({private: true});
let downloadLastDir = new DownloadLastDir(win); let downloadLastDir = new DownloadLastDir(win);
let pbDownloadLastDir = new DownloadLastDir(pbWin); let pbDownloadLastDir = new DownloadLastDir(pbWin);
@ -113,7 +100,7 @@ function runTest() {
"LastDir pref should be null to start with"); "LastDir pref should be null to start with");
// set up last dir // set up last dir
yield setFile(downloadLastDir, null, tmpDir); await setFile(downloadLastDir, null, tmpDir);
is(downloadLastDir.file.path, tmpDir.path, is(downloadLastDir.file.path, tmpDir.path,
"LastDir should point to the tmpDir"); "LastDir should point to the tmpDir");
isnot(downloadLastDir.file, tmpDir, isnot(downloadLastDir.file, tmpDir,
@ -121,111 +108,111 @@ function runTest() {
// set uri1 to dir1, all should now return dir1 // set uri1 to dir1, all should now return dir1
// also check that a new object is returned // also check that a new object is returned
yield setFile(downloadLastDir, uri1, dir1); await setFile(downloadLastDir, uri1, dir1);
is(downloadLastDir.file.path, dir1.path, is(downloadLastDir.file.path, dir1.path,
"downloadLastDir should return dir1"); "downloadLastDir should return dir1");
isnot(downloadLastDir.file, dir1, isnot(downloadLastDir.file, dir1,
"downloadLastDir.file should not return dir1"); "downloadLastDir.file should not return dir1");
is((yield getFile(downloadLastDir, uri1)).path, dir1.path, is((await getFile(downloadLastDir, uri1)).path, dir1.path,
"uri1 should return dir1"); // set in CPS "uri1 should return dir1"); // set in CPS
isnot((yield getFile(downloadLastDir, uri1)), dir1, isnot((await getFile(downloadLastDir, uri1)), dir1,
"getFile on uri1 should not return dir1"); "getFile on uri1 should not return dir1");
is((yield getFile(downloadLastDir, uri2)).path, dir1.path, is((await getFile(downloadLastDir, uri2)).path, dir1.path,
"uri2 should return dir1"); // fallback "uri2 should return dir1"); // fallback
isnot((yield getFile(downloadLastDir, uri2)), dir1, isnot((await getFile(downloadLastDir, uri2)), dir1,
"getFile on uri2 should not return dir1"); "getFile on uri2 should not return dir1");
is((yield getFile(downloadLastDir, uri3)).path, dir1.path, is((await getFile(downloadLastDir, uri3)).path, dir1.path,
"uri3 should return dir1"); // fallback "uri3 should return dir1"); // fallback
isnot((yield getFile(downloadLastDir, uri3)), dir1, isnot((await getFile(downloadLastDir, uri3)), dir1,
"getFile on uri3 should not return dir1"); "getFile on uri3 should not return dir1");
is((yield getFile(downloadLastDir, uri4)).path, dir1.path, is((await getFile(downloadLastDir, uri4)).path, dir1.path,
"uri4 should return dir1"); // fallback "uri4 should return dir1"); // fallback
isnot((yield getFile(downloadLastDir, uri4)), dir1, isnot((await getFile(downloadLastDir, uri4)), dir1,
"getFile on uri4 should not return dir1"); "getFile on uri4 should not return dir1");
// set uri2 to dir2, all except uri1 should now return dir2 // set uri2 to dir2, all except uri1 should now return dir2
yield setFile(downloadLastDir, uri2, dir2); await setFile(downloadLastDir, uri2, dir2);
is(downloadLastDir.file.path, dir2.path, is(downloadLastDir.file.path, dir2.path,
"downloadLastDir should point to dir2"); "downloadLastDir should point to dir2");
is((yield getFile(downloadLastDir, uri1)).path, dir1.path, is((await getFile(downloadLastDir, uri1)).path, dir1.path,
"uri1 should return dir1"); // set in CPS "uri1 should return dir1"); // set in CPS
is((yield getFile(downloadLastDir, uri2)).path, dir2.path, is((await getFile(downloadLastDir, uri2)).path, dir2.path,
"uri2 should return dir2"); // set in CPS "uri2 should return dir2"); // set in CPS
is((yield getFile(downloadLastDir, uri3)).path, dir2.path, is((await getFile(downloadLastDir, uri3)).path, dir2.path,
"uri3 should return dir2"); // fallback "uri3 should return dir2"); // fallback
is((yield getFile(downloadLastDir, uri4)).path, dir2.path, is((await getFile(downloadLastDir, uri4)).path, dir2.path,
"uri4 should return dir2"); // fallback "uri4 should return dir2"); // fallback
// set uri3 to dir3, all except uri1 and uri2 should now return dir3 // set uri3 to dir3, all except uri1 and uri2 should now return dir3
yield setFile(downloadLastDir, uri3, dir3); await setFile(downloadLastDir, uri3, dir3);
is(downloadLastDir.file.path, dir3.path, is(downloadLastDir.file.path, dir3.path,
"downloadLastDir should point to dir3"); "downloadLastDir should point to dir3");
is((yield getFile(downloadLastDir, uri1)).path, dir1.path, is((await getFile(downloadLastDir, uri1)).path, dir1.path,
"uri1 should return dir1"); // set in CPS "uri1 should return dir1"); // set in CPS
is((yield getFile(downloadLastDir, uri2)).path, dir2.path, is((await getFile(downloadLastDir, uri2)).path, dir2.path,
"uri2 should return dir2"); // set in CPS "uri2 should return dir2"); // set in CPS
is((yield getFile(downloadLastDir, uri3)).path, dir3.path, is((await getFile(downloadLastDir, uri3)).path, dir3.path,
"uri3 should return dir3"); // set in CPS "uri3 should return dir3"); // set in CPS
is((yield getFile(downloadLastDir, uri4)).path, dir3.path, is((await getFile(downloadLastDir, uri4)).path, dir3.path,
"uri4 should return dir4"); // fallback "uri4 should return dir4"); // fallback
// set uri1 to dir2, all except uri3 should now return dir2 // set uri1 to dir2, all except uri3 should now return dir2
yield setFile(downloadLastDir, uri1, dir2); await setFile(downloadLastDir, uri1, dir2);
is(downloadLastDir.file.path, dir2.path, is(downloadLastDir.file.path, dir2.path,
"downloadLastDir should point to dir2"); "downloadLastDir should point to dir2");
is((yield getFile(downloadLastDir, uri1)).path, dir2.path, is((await getFile(downloadLastDir, uri1)).path, dir2.path,
"uri1 should return dir2"); // set in CPS "uri1 should return dir2"); // set in CPS
is((yield getFile(downloadLastDir, uri2)).path, dir2.path, is((await getFile(downloadLastDir, uri2)).path, dir2.path,
"uri2 should return dir2"); // set in CPS "uri2 should return dir2"); // set in CPS
is((yield getFile(downloadLastDir, uri3)).path, dir3.path, is((await getFile(downloadLastDir, uri3)).path, dir3.path,
"uri3 should return dir3"); // set in CPS "uri3 should return dir3"); // set in CPS
is((yield getFile(downloadLastDir, uri4)).path, dir2.path, is((await getFile(downloadLastDir, uri4)).path, dir2.path,
"uri4 should return dir2"); // fallback "uri4 should return dir2"); // fallback
yield clearHistoryAndWait(); await clearHistoryAndWait();
// check clearHistory removes all data // check clearHistory removes all data
is(downloadLastDir.file, null, "clearHistory removes all data"); is(downloadLastDir.file, null, "clearHistory removes all data");
//is(Services.contentPrefs.hasPref(uri1, "browser.download.lastDir", null), //is(Services.contentPrefs.hasPref(uri1, "browser.download.lastDir", null),
// false, "LastDir preference should be absent"); // false, "LastDir preference should be absent");
is((yield getFile(downloadLastDir, uri1)), null, "uri1 should point to null"); is((await getFile(downloadLastDir, uri1)), null, "uri1 should point to null");
is((yield getFile(downloadLastDir, uri2)), null, "uri2 should point to null"); is((await getFile(downloadLastDir, uri2)), null, "uri2 should point to null");
is((yield getFile(downloadLastDir, uri3)), null, "uri3 should point to null"); is((await getFile(downloadLastDir, uri3)), null, "uri3 should point to null");
is((yield getFile(downloadLastDir, uri4)), null, "uri4 should point to null"); is((await getFile(downloadLastDir, uri4)), null, "uri4 should point to null");
yield setFile(downloadLastDir, null, tmpDir); await setFile(downloadLastDir, null, tmpDir);
// check data set outside PB mode is remembered // check data set outside PB mode is remembered
is((yield checkDownloadLastDir(pbDownloadLastDir, tmpDir)).path, tmpDir.path, "uri1 should return the expected last directory"); is((await checkDownloadLastDir(pbDownloadLastDir, tmpDir)).path, tmpDir.path, "uri1 should return the expected last directory");
is((yield checkDownloadLastDir(downloadLastDir, tmpDir)).path, tmpDir.path, "uri1 should return the expected last directory"); is((await checkDownloadLastDir(downloadLastDir, tmpDir)).path, tmpDir.path, "uri1 should return the expected last directory");
yield clearHistoryAndWait(); await clearHistoryAndWait();
yield setFile(downloadLastDir, uri1, dir1); await setFile(downloadLastDir, uri1, dir1);
// check data set using CPS outside PB mode is remembered // check data set using CPS outside PB mode is remembered
is((yield checkDownloadLastDir(pbDownloadLastDir, dir1)).path, dir1.path, "uri1 should return the expected last directory"); is((await checkDownloadLastDir(pbDownloadLastDir, dir1)).path, dir1.path, "uri1 should return the expected last directory");
is((yield checkDownloadLastDir(downloadLastDir, dir1)).path, dir1.path, "uri1 should return the expected last directory"); is((await checkDownloadLastDir(downloadLastDir, dir1)).path, dir1.path, "uri1 should return the expected last directory");
yield clearHistoryAndWait(); await clearHistoryAndWait();
// check data set inside PB mode is forgotten // check data set inside PB mode is forgotten
yield setFile(pbDownloadLastDir, null, tmpDir); await setFile(pbDownloadLastDir, null, tmpDir);
is((yield checkDownloadLastDir(pbDownloadLastDir, tmpDir)).path, tmpDir.path, "uri1 should return the expected last directory"); is((await checkDownloadLastDir(pbDownloadLastDir, tmpDir)).path, tmpDir.path, "uri1 should return the expected last directory");
is((yield checkDownloadLastDirNull(downloadLastDir)), null, "uri1 should return the expected last directory"); is((await checkDownloadLastDirNull(downloadLastDir)), null, "uri1 should return the expected last directory");
yield clearHistoryAndWait(); await clearHistoryAndWait();
// check data set using CPS inside PB mode is forgotten // check data set using CPS inside PB mode is forgotten
yield setFile(pbDownloadLastDir, uri1, dir1); await setFile(pbDownloadLastDir, uri1, dir1);
is((yield checkDownloadLastDir(pbDownloadLastDir, dir1)).path, dir1.path, "uri1 should return the expected last directory"); is((await checkDownloadLastDir(pbDownloadLastDir, dir1)).path, dir1.path, "uri1 should return the expected last directory");
is((yield checkDownloadLastDirNull(downloadLastDir)), null, "uri1 should return the expected last directory"); is((await checkDownloadLastDirNull(downloadLastDir)), null, "uri1 should return the expected last directory");
// check data set outside PB mode but changed inside is remembered correctly // check data set outside PB mode but changed inside is remembered correctly
yield setFile(downloadLastDir, uri1, dir1); await setFile(downloadLastDir, uri1, dir1);
yield setFile(pbDownloadLastDir, uri1, dir2); await setFile(pbDownloadLastDir, uri1, dir2);
is((yield checkDownloadLastDir(pbDownloadLastDir, dir2)).path, dir2.path, "uri1 should return the expected last directory"); is((await checkDownloadLastDir(pbDownloadLastDir, dir2)).path, dir2.path, "uri1 should return the expected last directory");
is((yield checkDownloadLastDir(downloadLastDir, dir1)).path, dir1.path, "uri1 should return the expected last directory"); is((await checkDownloadLastDir(downloadLastDir, dir1)).path, dir1.path, "uri1 should return the expected last directory");
/* /*
* ==================== * ====================
@ -236,47 +223,49 @@ function runTest() {
// check that the last dir store got cleared in a new PB window // check that the last dir store got cleared in a new PB window
pbWin.close(); pbWin.close();
// And give it time to close // And give it time to close
executeSoon(moveAlong); await new Promise(resolve => executeSoon(resolve));
yield;
pbWin = yield createWindow({private: true}); pbWin = await createWindow({private: true});
pbDownloadLastDir = new DownloadLastDir(pbWin); pbDownloadLastDir = new DownloadLastDir(pbWin);
is((yield checkDownloadLastDir(pbDownloadLastDir, dir1)).path, dir1.path, "uri1 should return the expected last directory"); is((await checkDownloadLastDir(pbDownloadLastDir, dir1)).path, dir1.path, "uri1 should return the expected last directory");
yield clearHistoryAndWait(); await clearHistoryAndWait();
// check clearHistory inside PB mode clears data outside PB mode // check clearHistory inside PB mode clears data outside PB mode
yield setFile(pbDownloadLastDir, uri1, dir2); await setFile(pbDownloadLastDir, uri1, dir2);
yield clearHistoryAndWait(); await clearHistoryAndWait();
is((yield checkDownloadLastDirNull(downloadLastDir)), null, "uri1 should return the expected last directory"); is((await checkDownloadLastDirNull(downloadLastDir)), null, "uri1 should return the expected last directory");
is((yield checkDownloadLastDirNull(pbDownloadLastDir)), null, "uri1 should return the expected last directory"); is((await checkDownloadLastDirNull(pbDownloadLastDir)), null, "uri1 should return the expected last directory");
// check that disabling CPS works // check that disabling CPS works
Services.prefs.setBoolPref("browser.download.lastDir.savePerSite", false); Services.prefs.setBoolPref("browser.download.lastDir.savePerSite", false);
yield setFile(downloadLastDir, uri1, dir1); await setFile(downloadLastDir, uri1, dir1);
is(downloadLastDir.file.path, dir1.path, "LastDir should be set to dir1"); is(downloadLastDir.file.path, dir1.path, "LastDir should be set to dir1");
is((yield getFile(downloadLastDir, uri1)).path, dir1.path, "uri1 should return dir1"); is((await getFile(downloadLastDir, uri1)).path, dir1.path, "uri1 should return dir1");
is((yield getFile(downloadLastDir, uri2)).path, dir1.path, "uri2 should return dir1"); is((await getFile(downloadLastDir, uri2)).path, dir1.path, "uri2 should return dir1");
is((yield getFile(downloadLastDir, uri3)).path, dir1.path, "uri3 should return dir1"); is((await getFile(downloadLastDir, uri3)).path, dir1.path, "uri3 should return dir1");
is((yield getFile(downloadLastDir, uri4)).path, dir1.path, "uri4 should return dir1"); is((await getFile(downloadLastDir, uri4)).path, dir1.path, "uri4 should return dir1");
downloadLastDir.setFile(uri2, dir2); downloadLastDir.setFile(uri2, dir2);
is(downloadLastDir.file.path, dir2.path, "LastDir should be set to dir2"); is(downloadLastDir.file.path, dir2.path, "LastDir should be set to dir2");
is((yield getFile(downloadLastDir, uri1)).path, dir2.path, "uri1 should return dir2"); is((await getFile(downloadLastDir, uri1)).path, dir2.path, "uri1 should return dir2");
is((yield getFile(downloadLastDir, uri2)).path, dir2.path, "uri2 should return dir2"); is((await getFile(downloadLastDir, uri2)).path, dir2.path, "uri2 should return dir2");
is((yield getFile(downloadLastDir, uri3)).path, dir2.path, "uri3 should return dir2"); is((await getFile(downloadLastDir, uri3)).path, dir2.path, "uri3 should return dir2");
is((yield getFile(downloadLastDir, uri4)).path, dir2.path, "uri4 should return dir2"); is((await getFile(downloadLastDir, uri4)).path, dir2.path, "uri4 should return dir2");
Services.prefs.clearUserPref("browser.download.lastDir.savePerSite"); Services.prefs.clearUserPref("browser.download.lastDir.savePerSite");
// check that passing null to setFile clears the stored value // check that passing null to setFile clears the stored value
yield setFile(downloadLastDir, uri3, dir3); await setFile(downloadLastDir, uri3, dir3);
is((yield getFile(downloadLastDir, uri3)).path, dir3.path, "LastDir should be set to dir3"); is((await getFile(downloadLastDir, uri3)).path, dir3.path, "LastDir should be set to dir3");
yield setFile(downloadLastDir, uri3, null); await setFile(downloadLastDir, uri3, null);
is((yield getFile(downloadLastDir, uri3)), null, "uri3 should return null"); is((await getFile(downloadLastDir, uri3)), null, "uri3 should return null");
yield clearHistoryAndWait(); await clearHistoryAndWait();
finish();
} }

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

@ -17,7 +17,7 @@ add_task(function* setup() {
}); });
}); });
add_task(function test() { add_task(function* test() {
let prefix = 'http://mochi.test:8888/browser/browser/components/privatebrowsing/test/browser/browser_privatebrowsing_concurrent_page.html'; let prefix = 'http://mochi.test:8888/browser/browser/components/privatebrowsing/test/browser/browser_privatebrowsing_concurrent_page.html';
function getElts(browser) { function getElts(browser) {

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

@ -5,7 +5,7 @@
// This test makes sure that the Clear Recent History menu item and command // This test makes sure that the Clear Recent History menu item and command
// is disabled inside the private browsing mode. // is disabled inside the private browsing mode.
add_task(function test() { add_task(function* test() {
function checkDisableOption(aPrivateMode, aWindow) { function checkDisableOption(aPrivateMode, aWindow) {
let crhCommand = aWindow.document.getElementById("Tools:Sanitize"); let crhCommand = aWindow.document.getElementById("Tools:Sanitize");
ok(crhCommand, "The clear recent history command should exist"); ok(crhCommand, "The clear recent history command should exist");

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

@ -75,31 +75,29 @@ add_task(function* test_downloads_last_dir_toggle() {
* *
* @returns Promise * @returns Promise
*/ */
function testHelper(options) { async function testHelper(options) {
return new Task.spawn(function() { let win = await BrowserTestUtils.openNewBrowserWindow(options);
let win = yield BrowserTestUtils.openNewBrowserWindow(options); let gDownloadLastDir = new DownloadLastDir(win);
let gDownloadLastDir = new DownloadLastDir(win);
if (options.clearHistory) { if (options.clearHistory) {
clearHistory(); clearHistory();
} }
if (options.setDir) { if (options.setDir) {
gDownloadLastDir.file = options.setDir; gDownloadLastDir.file = options.setDir;
} }
let expectedDir = options.expectedDir; let expectedDir = options.expectedDir;
if (expectedDir) { if (expectedDir) {
is(gDownloadLastDir.file.path, expectedDir.path, is(gDownloadLastDir.file.path, expectedDir.path,
"gDownloadLastDir should point to the expected last directory"); "gDownloadLastDir should point to the expected last directory");
isnot(gDownloadLastDir.file, expectedDir, isnot(gDownloadLastDir.file, expectedDir,
"gDownloadLastDir.file should not be pointing to the last directory"); "gDownloadLastDir.file should not be pointing to the last directory");
} else { } else {
is(gDownloadLastDir.file, null, "gDownloadLastDir should be null"); is(gDownloadLastDir.file, null, "gDownloadLastDir should be null");
} }
gDownloadLastDir.cleanupPrivateFile(); gDownloadLastDir.cleanupPrivateFile();
yield BrowserTestUtils.closeWindow(win); await BrowserTestUtils.closeWindow(win);
});
} }

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

@ -2,7 +2,7 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this * License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
add_task(function test() { add_task(function* test() {
requestLongerTimeout(2); requestLongerTimeout(2);
const page1 = 'http://mochi.test:8888/browser/browser/components/privatebrowsing/test/browser/' + const page1 = 'http://mochi.test:8888/browser/browser/components/privatebrowsing/test/browser/' +
'browser_privatebrowsing_localStorage_page1.html' 'browser_privatebrowsing_localStorage_page1.html'

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

@ -10,7 +10,7 @@
// Step 2: Load the same page in a non-private tab, ensuring that the storage instance reports only one item // Step 2: Load the same page in a non-private tab, ensuring that the storage instance reports only one item
// existing. // existing.
add_task(function test() { add_task(function* test() {
let testURI = "about:blank"; let testURI = "about:blank";
let prefix = 'http://mochi.test:8888/browser/browser/components/privatebrowsing/test/browser/'; let prefix = 'http://mochi.test:8888/browser/browser/components/privatebrowsing/test/browser/';

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

@ -5,7 +5,7 @@
// This test makes sure that the window title changes correctly while switching // This test makes sure that the window title changes correctly while switching
// from and to private browsing mode. // from and to private browsing mode.
add_task(function test() { add_task(function* test() {
const testPageURL = "http://mochi.test:8888/browser/" + const testPageURL = "http://mochi.test:8888/browser/" +
"browser/components/privatebrowsing/test/browser/browser_privatebrowsing_windowtitle_page.html"; "browser/components/privatebrowsing/test/browser/browser_privatebrowsing_windowtitle_page.html";
requestLongerTimeout(2); requestLongerTimeout(2);
@ -37,12 +37,12 @@ add_task(function test() {
pb_about_pb_title = "Private Browsing - " + app_name + " (Private Browsing)"; pb_about_pb_title = "Private Browsing - " + app_name + " (Private Browsing)";
} }
function* testTabTitle(aWindow, url, insidePB, expected_title) { async function testTabTitle(aWindow, url, insidePB, expected_title) {
let tab = (yield BrowserTestUtils.openNewForegroundTab(aWindow.gBrowser)); let tab = (await BrowserTestUtils.openNewForegroundTab(aWindow.gBrowser));
yield BrowserTestUtils.loadURI(tab.linkedBrowser, url); await BrowserTestUtils.loadURI(tab.linkedBrowser, url);
yield BrowserTestUtils.browserLoaded(tab.linkedBrowser); await BrowserTestUtils.browserLoaded(tab.linkedBrowser);
yield BrowserTestUtils.waitForCondition(() => { await BrowserTestUtils.waitForCondition(() => {
return aWindow.document.title === expected_title; return aWindow.document.title === expected_title;
}, `Window title should be ${expected_title}, got ${aWindow.document.title}`); }, `Window title should be ${expected_title}, got ${aWindow.document.title}`);
@ -51,9 +51,9 @@ add_task(function test() {
" private browsing mode)"); " private browsing mode)");
let win = aWindow.gBrowser.replaceTabWithWindow(tab); let win = aWindow.gBrowser.replaceTabWithWindow(tab);
yield BrowserTestUtils.waitForEvent(win, "load", false); await BrowserTestUtils.waitForEvent(win, "load", false);
yield BrowserTestUtils.waitForCondition(() => { await BrowserTestUtils.waitForCondition(() => {
return win.document.title === expected_title; return win.document.title === expected_title;
}, `Window title should be ${expected_title}, got ${aWindow.document.title}`); }, `Window title should be ${expected_title}, got ${aWindow.document.title}`);
@ -61,17 +61,17 @@ add_task(function test() {
" detached tab is correct (" + (insidePB ? "inside" : "outside") + " detached tab is correct (" + (insidePB ? "inside" : "outside") +
" private browsing mode)"); " private browsing mode)");
yield Promise.all([ BrowserTestUtils.closeWindow(win), await Promise.all([ BrowserTestUtils.closeWindow(win),
BrowserTestUtils.closeWindow(aWindow) ]); BrowserTestUtils.closeWindow(aWindow) ]);
} }
function openWin(private) { function openWin(private) {
return BrowserTestUtils.openNewBrowserWindow({ private }); return BrowserTestUtils.openNewBrowserWindow({ private });
} }
yield Task.spawn(testTabTitle((yield openWin(false)), "about:blank", false, page_without_title)); yield testTabTitle((yield openWin(false)), "about:blank", false, page_without_title);
yield Task.spawn(testTabTitle((yield openWin(false)), testPageURL, false, page_with_title)); yield testTabTitle((yield openWin(false)), testPageURL, false, page_with_title);
yield Task.spawn(testTabTitle((yield openWin(false)), "about:privatebrowsing", false, about_pb_title)); yield testTabTitle((yield openWin(false)), "about:privatebrowsing", false, about_pb_title);
yield Task.spawn(testTabTitle((yield openWin(true)), "about:blank", true, pb_page_without_title)); yield testTabTitle((yield openWin(true)), "about:blank", true, pb_page_without_title);
yield Task.spawn(testTabTitle((yield openWin(true)), testPageURL, true, pb_page_with_title)); yield testTabTitle((yield openWin(true)), testPageURL, true, pb_page_with_title);
yield Task.spawn(testTabTitle((yield openWin(true)), "about:privatebrowsing", true, pb_about_pb_title)); yield testTabTitle((yield openWin(true)), "about:privatebrowsing", true, pb_about_pb_title);
}); });

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

@ -66,11 +66,11 @@ var SessionMigrationInternal = {
* Asynchronously read session restore state (JSON) from a path * Asynchronously read session restore state (JSON) from a path
*/ */
readState: function(aPath) { readState: function(aPath) {
return Task.spawn(function() { return Task.spawn(function*() {
let bytes = yield OS.File.read(aPath); let bytes = yield OS.File.read(aPath);
let text = gDecoder.decode(bytes); let text = gDecoder.decode(bytes);
let state = JSON.parse(text); let state = JSON.parse(text);
throw new Task.Result(state); return state;
}); });
}, },
/** /**
@ -87,7 +87,7 @@ var SessionMigration = {
* Migrate a limited set of session data from one path to another. * Migrate a limited set of session data from one path to another.
*/ */
migrate: function(aFromPath, aToPath) { migrate: function(aFromPath, aToPath) {
return Task.spawn(function() { return Task.spawn(function*() {
let inState = yield SessionMigrationInternal.readState(aFromPath); let inState = yield SessionMigrationInternal.readState(aFromPath);
let outState = SessionMigrationInternal.convertState(inState); let outState = SessionMigrationInternal.convertState(inState);
// Unfortunately, we can't use SessionStore's own SessionFile to // Unfortunately, we can't use SessionStore's own SessionFile to

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

@ -8,7 +8,7 @@ const URL = "about:config";
/** /**
* Bug 393716 - Basic tests for getTabState(), setTabState(), and duplicateTab(). * Bug 393716 - Basic tests for getTabState(), setTabState(), and duplicateTab().
*/ */
add_task(function test_set_tabstate() { add_task(function* test_set_tabstate() {
let key = "Unique key: " + Date.now(); let key = "Unique key: " + Date.now();
let value = "Unique value: " + Math.random(); let value = "Unique value: " + Math.random();
@ -35,7 +35,7 @@ add_task(function test_set_tabstate() {
gBrowser.removeTab(tab); gBrowser.removeTab(tab);
}); });
add_task(function test_set_tabstate_and_duplicate() { add_task(function* test_set_tabstate_and_duplicate() {
let key2 = "key2"; let key2 = "key2";
let value2 = "Value " + Math.random(); let value2 = "Value " + Math.random();
let value3 = "Another value: " + Date.now(); let value3 = "Another value: " + Date.now();

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

@ -8,7 +8,7 @@ const URL = ROOT + "browser_456342_sample.xhtml";
/** /**
* Bug 456342 - Restore values from non-standard input field types. * Bug 456342 - Restore values from non-standard input field types.
*/ */
add_task(function test_restore_nonstandard_input_values() { add_task(function* test_restore_nonstandard_input_values() {
// Add tab with various non-standard input field types. // Add tab with various non-standard input field types.
let tab = gBrowser.addTab(URL); let tab = gBrowser.addTab(URL);
let browser = tab.linkedBrowser; let browser = tab.linkedBrowser;

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

@ -10,7 +10,7 @@ const URL = ROOT + "browser_463205_sample.html";
* website can't modify frame URLs and make us inject form data into the wrong * website can't modify frame URLs and make us inject form data into the wrong
* web pages. * web pages.
*/ */
add_task(function test_check_urls_before_restoring() { add_task(function* test_check_urls_before_restoring() {
// Add a blank tab. // Add a blank tab.
let tab = gBrowser.addTab("about:blank"); let tab = gBrowser.addTab("about:blank");
let browser = tab.linkedBrowser; let browser = tab.linkedBrowser;

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

@ -8,7 +8,7 @@ const URL = ROOT + "browser_466937_sample.html";
/** /**
* Bug 466937 - Prevent file stealing with sessionstore. * Bug 466937 - Prevent file stealing with sessionstore.
*/ */
add_task(function test_prevent_file_stealing() { add_task(function* test_prevent_file_stealing() {
// Add a tab with some file input fields. // Add a tab with some file input fields.
let tab = gBrowser.addTab(URL); let tab = gBrowser.addTab(URL);
let browser = tab.linkedBrowser; let browser = tab.linkedBrowser;

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

@ -30,7 +30,7 @@ function createEntries(sessionData) {
}; };
} }
add_task(function test_nested_about_sessionrestore() { add_task(function* test_nested_about_sessionrestore() {
// Prepare a blank tab. // Prepare a blank tab.
let tab = gBrowser.addTab("about:blank"); let tab = gBrowser.addTab("about:blank");
let browser = tab.linkedBrowser; let browser = tab.linkedBrowser;

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

@ -9,7 +9,7 @@ const URL = ROOT + "browser_485482_sample.html";
* Bug 485482 - Make sure that we produce valid XPath expressions even for very * Bug 485482 - Make sure that we produce valid XPath expressions even for very
* weird HTML documents. * weird HTML documents.
*/ */
add_task(function test_xpath_exp_for_strange_documents() { add_task(function* test_xpath_exp_for_strange_documents() {
// Load a page with weird tag names. // Load a page with weird tag names.
let tab = gBrowser.addTab(URL); let tab = gBrowser.addTab(URL);
let browser = tab.linkedBrowser; let browser = tab.linkedBrowser;

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

@ -11,7 +11,7 @@ function browserWindowsCount(expected) {
"number of open browser windows according to getBrowserState"); "number of open browser windows according to getBrowserState");
} }
add_task(function() { add_task(function*() {
browserWindowsCount(1); browserWindowsCount(1);
let win = yield BrowserTestUtils.openNewBrowserWindow(); let win = yield BrowserTestUtils.openNewBrowserWindow();

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

@ -9,7 +9,7 @@ const INITIAL_VALUE = "browser_broadcast.js-initial-value-" + Date.now();
* This test ensures we won't lose tab data queued in the content script when * This test ensures we won't lose tab data queued in the content script when
* closing a tab. * closing a tab.
*/ */
add_task(function flush_on_tabclose() { add_task(function* flush_on_tabclose() {
let tab = yield createTabWithStorageData(["http://example.com"]); let tab = yield createTabWithStorageData(["http://example.com"]);
let browser = tab.linkedBrowser; let browser = tab.linkedBrowser;
@ -25,7 +25,7 @@ add_task(function flush_on_tabclose() {
* This test ensures we won't lose tab data queued in the content script when * This test ensures we won't lose tab data queued in the content script when
* duplicating a tab. * duplicating a tab.
*/ */
add_task(function flush_on_duplicate() { add_task(function* flush_on_duplicate() {
let tab = yield createTabWithStorageData(["http://example.com"]); let tab = yield createTabWithStorageData(["http://example.com"]);
let browser = tab.linkedBrowser; let browser = tab.linkedBrowser;
@ -45,7 +45,7 @@ add_task(function flush_on_duplicate() {
* This test ensures we won't lose tab data queued in the content script when * This test ensures we won't lose tab data queued in the content script when
* a window is closed. * a window is closed.
*/ */
add_task(function flush_on_windowclose() { add_task(function* flush_on_windowclose() {
let win = yield promiseNewWindow(); let win = yield promiseNewWindow();
let tab = yield createTabWithStorageData(["http://example.com"], win); let tab = yield createTabWithStorageData(["http://example.com"], win);
let browser = tab.linkedBrowser; let browser = tab.linkedBrowser;
@ -62,7 +62,7 @@ add_task(function flush_on_windowclose() {
* This test ensures that stale tab data is ignored when reusing a tab * This test ensures that stale tab data is ignored when reusing a tab
* (via e.g. setTabState) and does not overwrite the new data. * (via e.g. setTabState) and does not overwrite the new data.
*/ */
add_task(function flush_on_settabstate() { add_task(function* flush_on_settabstate() {
let tab = yield createTabWithStorageData(["http://example.com"]); let tab = yield createTabWithStorageData(["http://example.com"]);
let browser = tab.linkedBrowser; let browser = tab.linkedBrowser;
@ -90,7 +90,7 @@ add_task(function flush_on_settabstate() {
* asynchronously just before closing a tab. Flushing must re-send all data * asynchronously just before closing a tab. Flushing must re-send all data
* that hasn't been received by chrome, yet. * that hasn't been received by chrome, yet.
*/ */
add_task(function flush_on_tabclose_racy() { add_task(function* flush_on_tabclose_racy() {
let tab = yield createTabWithStorageData(["http://example.com"]); let tab = yield createTabWithStorageData(["http://example.com"]);
let browser = tab.linkedBrowser; let browser = tab.linkedBrowser;
@ -115,17 +115,15 @@ function promiseNewWindow() {
return deferred.promise; return deferred.promise;
} }
function createTabWithStorageData(urls, win = window) { async function createTabWithStorageData(urls, win = window) {
return Task.spawn(function task() { let tab = win.gBrowser.addTab();
let tab = win.gBrowser.addTab(); let browser = tab.linkedBrowser;
let browser = tab.linkedBrowser;
for (let url of urls) { for (let url of urls) {
browser.loadURI(url); browser.loadURI(url);
yield promiseBrowserLoaded(browser); await promiseBrowserLoaded(browser);
yield modifySessionStorage(browser, {test: INITIAL_VALUE}); await modifySessionStorage(browser, {test: INITIAL_VALUE});
} }
throw new Task.Result(tab); return tab;
});
} }

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

@ -8,7 +8,7 @@
* properties are (re)stored as disabled. Disallowed features must be * properties are (re)stored as disabled. Disallowed features must be
* re-enabled when the tab is re-used by another tab restoration. * re-enabled when the tab is re-used by another tab restoration.
*/ */
add_task(function docshell_capabilities() { add_task(function* docshell_capabilities() {
let tab = yield createTab(); let tab = yield createTab();
let browser = tab.linkedBrowser; let browser = tab.linkedBrowser;
let docShell = browser.docShell; let docShell = browser.docShell;
@ -69,8 +69,9 @@ add_task(function docshell_capabilities() {
gBrowser.removeTab(tab); gBrowser.removeTab(tab);
}); });
function createTab() { async function createTab() {
let tab = gBrowser.addTab("about:mozilla"); let tab = gBrowser.addTab("about:mozilla");
let browser = tab.linkedBrowser; let browser = tab.linkedBrowser;
return promiseBrowserLoaded(browser).then(() => tab); await promiseBrowserLoaded(browser);
return tab;
} }

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

@ -84,7 +84,7 @@ add_task(function* test_run() {
* different cookie domains given in the Set-Cookie header. See above for some * different cookie domains given in the Set-Cookie header. See above for some
* usage examples. * usage examples.
*/ */
var testCookieCollection = Task.async(function (params) { var testCookieCollection = async function (params) {
let tab = gBrowser.addTab("about:blank"); let tab = gBrowser.addTab("about:blank");
let browser = tab.linkedBrowser; let browser = tab.linkedBrowser;
@ -102,14 +102,14 @@ var testCookieCollection = Task.async(function (params) {
// Wait for the browser to load and the cookie to be set. // Wait for the browser to load and the cookie to be set.
// These two events can probably happen in no particular order, // These two events can probably happen in no particular order,
// so let's wait for them in parallel. // so let's wait for them in parallel.
yield Promise.all([ await Promise.all([
waitForNewCookie(), waitForNewCookie(),
replaceCurrentURI(browser, uri) replaceCurrentURI(browser, uri)
]); ]);
// Check all URIs for which the cookie should be collected. // Check all URIs for which the cookie should be collected.
for (let uri of params.cookieURIs || []) { for (let uri of params.cookieURIs || []) {
yield replaceCurrentURI(browser, uri); await replaceCurrentURI(browser, uri);
// Check the cookie. // Check the cookie.
let cookie = getCookie(); let cookie = getCookie();
@ -121,7 +121,7 @@ var testCookieCollection = Task.async(function (params) {
// Check all URIs for which the cookie should NOT be collected. // Check all URIs for which the cookie should NOT be collected.
for (let uri of params.noCookieURIs || []) { for (let uri of params.noCookieURIs || []) {
yield replaceCurrentURI(browser, uri); await replaceCurrentURI(browser, uri);
// Cookie should be ignored. // Cookie should be ignored.
ok(!getCookie(), "no cookie collected"); ok(!getCookie(), "no cookie collected");
@ -130,22 +130,22 @@ var testCookieCollection = Task.async(function (params) {
// Clean up. // Clean up.
gBrowser.removeTab(tab); gBrowser.removeTab(tab);
Services.cookies.removeAll(); Services.cookies.removeAll();
}); };
/** /**
* Replace the current URI of the given browser by loading a new URI. The * Replace the current URI of the given browser by loading a new URI. The
* browser's session history will be completely replaced. This function ensures * browser's session history will be completely replaced. This function ensures
* that the parent process has the lastest shistory data before resolving. * that the parent process has the lastest shistory data before resolving.
*/ */
var replaceCurrentURI = Task.async(function* (browser, uri) { var replaceCurrentURI = async function(browser, uri) {
// Replace the tab's current URI with the parent domain. // Replace the tab's current URI with the parent domain.
let flags = Ci.nsIWebNavigation.LOAD_FLAGS_REPLACE_HISTORY; let flags = Ci.nsIWebNavigation.LOAD_FLAGS_REPLACE_HISTORY;
browser.loadURIWithFlags(uri, flags); browser.loadURIWithFlags(uri, flags);
yield promiseBrowserLoaded(browser); await promiseBrowserLoaded(browser);
// Ensure the tab's session history is up-to-date. // Ensure the tab's session history is up-to-date.
yield TabStateFlusher.flush(browser); await TabStateFlusher.flush(browser);
}); };
/** /**
* Waits for a new "*example.com" cookie to be added. * Waits for a new "*example.com" cookie to be added.

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

@ -125,7 +125,7 @@ function promiseTabCrashedReady(browser) {
* Checks that if a tab crashes, that information about the tab crashed * Checks that if a tab crashes, that information about the tab crashed
* page does not get added to the tab history. * page does not get added to the tab history.
*/ */
add_task(function test_crash_page_not_in_history() { add_task(function* test_crash_page_not_in_history() {
let newTab = gBrowser.addTab(); let newTab = gBrowser.addTab();
gBrowser.selectedTab = newTab; gBrowser.selectedTab = newTab;
let browser = newTab.linkedBrowser; let browser = newTab.linkedBrowser;
@ -154,7 +154,7 @@ add_task(function test_crash_page_not_in_history() {
* to a non-blacklisted site (so the browser becomes remote again), that * to a non-blacklisted site (so the browser becomes remote again), that
* we record history for that new visit. * we record history for that new visit.
*/ */
add_task(function test_revived_history_from_remote() { add_task(function* test_revived_history_from_remote() {
let newTab = gBrowser.addTab(); let newTab = gBrowser.addTab();
gBrowser.selectedTab = newTab; gBrowser.selectedTab = newTab;
let browser = newTab.linkedBrowser; let browser = newTab.linkedBrowser;
@ -193,7 +193,7 @@ add_task(function test_revived_history_from_remote() {
* to a blacklisted site (so the browser stays non-remote), that * to a blacklisted site (so the browser stays non-remote), that
* we record history for that new visit. * we record history for that new visit.
*/ */
add_task(function test_revived_history_from_non_remote() { add_task(function* test_revived_history_from_non_remote() {
let newTab = gBrowser.addTab(); let newTab = gBrowser.addTab();
gBrowser.selectedTab = newTab; gBrowser.selectedTab = newTab;
let browser = newTab.linkedBrowser; let browser = newTab.linkedBrowser;
@ -231,7 +231,7 @@ add_task(function test_revived_history_from_non_remote() {
* Checks that we can revive a crashed tab back to the page that * Checks that we can revive a crashed tab back to the page that
* it was on when it crashed. * it was on when it crashed.
*/ */
add_task(function test_revive_tab_from_session_store() { add_task(function* test_revive_tab_from_session_store() {
let newTab = gBrowser.addTab(); let newTab = gBrowser.addTab();
gBrowser.selectedTab = newTab; gBrowser.selectedTab = newTab;
let browser = newTab.linkedBrowser; let browser = newTab.linkedBrowser;
@ -284,7 +284,7 @@ add_task(function test_revive_tab_from_session_store() {
* Checks that we can revive multiple crashed tabs back to the pages * Checks that we can revive multiple crashed tabs back to the pages
* that they were on when they crashed. * that they were on when they crashed.
*/ */
add_task(function test_revive_all_tabs_from_session_store() { add_task(function* test_revive_all_tabs_from_session_store() {
let newTab = gBrowser.addTab(); let newTab = gBrowser.addTab();
gBrowser.selectedTab = newTab; gBrowser.selectedTab = newTab;
let browser = newTab.linkedBrowser; let browser = newTab.linkedBrowser;
@ -344,7 +344,7 @@ add_task(function test_revive_all_tabs_from_session_store() {
/** /**
* Checks that about:tabcrashed can close the current tab * Checks that about:tabcrashed can close the current tab
*/ */
add_task(function test_close_tab_after_crash() { add_task(function* test_close_tab_after_crash() {
let newTab = gBrowser.addTab(); let newTab = gBrowser.addTab();
gBrowser.selectedTab = newTab; gBrowser.selectedTab = newTab;
let browser = newTab.linkedBrowser; let browser = newTab.linkedBrowser;

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

@ -7,7 +7,7 @@
* Ensure that static frames of framesets are serialized but dynamically * Ensure that static frames of framesets are serialized but dynamically
* inserted iframes are ignored. * inserted iframes are ignored.
*/ */
add_task(function () { add_task(function*() {
// This URL has the following frames: // This URL has the following frames:
// + data:text/html,A (static) // + data:text/html,A (static)
// + data:text/html,B (static) // + data:text/html,B (static)
@ -45,7 +45,7 @@ add_task(function () {
* dynamically inserted iframes are ignored. Navigating a subframe should * dynamically inserted iframes are ignored. Navigating a subframe should
* create a second root entry that doesn't contain any dynamic children either. * create a second root entry that doesn't contain any dynamic children either.
*/ */
add_task(function () { add_task(function*() {
// This URL has the following frames: // This URL has the following frames:
// + data:text/html,A (static) // + data:text/html,A (static)
// + data:text/html,C (dynamic iframe) // + data:text/html,C (dynamic iframe)

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

@ -9,7 +9,7 @@ const URL = ROOT + "browser_form_restore_events_sample.html";
* Originally a test for Bug 476161, but then expanded to include all input * Originally a test for Bug 476161, but then expanded to include all input
* types in bug 640136. * types in bug 640136.
*/ */
add_task(function () { add_task(function*() {
// Load a page with some form elements. // Load a page with some form elements.
let tab = gBrowser.addTab(URL); let tab = gBrowser.addTab(URL);
let browser = tab.linkedBrowser; let browser = tab.linkedBrowser;

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

@ -9,7 +9,7 @@ requestLongerTimeout(2);
* This test ensures that form data collection respects the privacy level as * This test ensures that form data collection respects the privacy level as
* set by the user. * set by the user.
*/ */
add_task(function test_formdata() { add_task(function* test_formdata() {
const URL = "http://mochi.test:8888/browser/browser/components/" + const URL = "http://mochi.test:8888/browser/browser/components/" +
"sessionstore/test/browser_formdata_sample.html"; "sessionstore/test/browser_formdata_sample.html";
@ -18,23 +18,21 @@ add_task(function test_formdata() {
// Creates a tab, loads a page with some form fields, // Creates a tab, loads a page with some form fields,
// modifies their values and closes the tab. // modifies their values and closes the tab.
function createAndRemoveTab() { function* createAndRemoveTab() {
return Task.spawn(function () { // Create a new tab.
// Create a new tab. let tab = gBrowser.addTab(URL);
let tab = gBrowser.addTab(URL); let browser = tab.linkedBrowser;
let browser = tab.linkedBrowser; yield promiseBrowserLoaded(browser);
yield promiseBrowserLoaded(browser);
// Modify form data. // Modify form data.
yield setInputValue(browser, {id: "txt", value: OUTER_VALUE}); yield setInputValue(browser, {id: "txt", value: OUTER_VALUE});
yield setInputValue(browser, {id: "txt", value: INNER_VALUE, frame: 0}); yield setInputValue(browser, {id: "txt", value: INNER_VALUE, frame: 0});
// Remove the tab. // Remove the tab.
yield promiseRemoveTab(tab); yield promiseRemoveTab(tab);
});
} }
yield createAndRemoveTab(); yield* createAndRemoveTab();
let [{state: {formdata}}] = JSON.parse(ss.getClosedTabData(window)); let [{state: {formdata}}] = JSON.parse(ss.getClosedTabData(window));
is(formdata.id.txt, OUTER_VALUE, "outer value is correct"); is(formdata.id.txt, OUTER_VALUE, "outer value is correct");
is(formdata.children[0].id.txt, INNER_VALUE, "inner value is correct"); is(formdata.children[0].id.txt, INNER_VALUE, "inner value is correct");
@ -42,7 +40,7 @@ add_task(function test_formdata() {
// Disable saving data for encrypted sites. // Disable saving data for encrypted sites.
Services.prefs.setIntPref("browser.sessionstore.privacy_level", 1); Services.prefs.setIntPref("browser.sessionstore.privacy_level", 1);
yield createAndRemoveTab(); yield* createAndRemoveTab();
[{state: {formdata}}] = JSON.parse(ss.getClosedTabData(window)); [{state: {formdata}}] = JSON.parse(ss.getClosedTabData(window));
is(formdata.id.txt, OUTER_VALUE, "outer value is correct"); is(formdata.id.txt, OUTER_VALUE, "outer value is correct");
ok(!formdata.children, "inner value was *not* stored"); ok(!formdata.children, "inner value was *not* stored");
@ -50,7 +48,7 @@ add_task(function test_formdata() {
// Disable saving data for any site. // Disable saving data for any site.
Services.prefs.setIntPref("browser.sessionstore.privacy_level", 2); Services.prefs.setIntPref("browser.sessionstore.privacy_level", 2);
yield createAndRemoveTab(); yield* createAndRemoveTab();
[{state: {formdata}}] = JSON.parse(ss.getClosedTabData(window)); [{state: {formdata}}] = JSON.parse(ss.getClosedTabData(window));
ok(!formdata, "form data has *not* been stored"); ok(!formdata, "form data has *not* been stored");
@ -63,7 +61,7 @@ add_task(function test_formdata() {
* form data into a wrong website and that we always check the stored URL * form data into a wrong website and that we always check the stored URL
* before doing so. * before doing so.
*/ */
add_task(function test_url_check() { add_task(function* test_url_check() {
const URL = "data:text/html;charset=utf-8,<input%20id=input>"; const URL = "data:text/html;charset=utf-8,<input%20id=input>";
const VALUE = "value-" + Math.random(); const VALUE = "value-" + Math.random();
@ -98,7 +96,7 @@ add_task(function test_url_check() {
* This test ensures that collecting form data works as expected when having * This test ensures that collecting form data works as expected when having
* nested frame sets. * nested frame sets.
*/ */
add_task(function test_nested() { add_task(function* test_nested() {
const URL = "data:text/html;charset=utf-8," + const URL = "data:text/html;charset=utf-8," +
"<iframe src='data:text/html;charset=utf-8," + "<iframe src='data:text/html;charset=utf-8," +
"<input autofocus=true>'/>"; "<input autofocus=true>'/>";
@ -143,7 +141,7 @@ add_task(function test_nested() {
* This test ensures that collecting form data for documents with * This test ensures that collecting form data for documents with
* designMode=on works as expected. * designMode=on works as expected.
*/ */
add_task(function test_design_mode() { add_task(function* test_design_mode() {
const URL = "data:text/html;charset=utf-8,<h1>mozilla</h1>" + const URL = "data:text/html;charset=utf-8,<h1>mozilla</h1>" +
"<script>document.designMode='on'</script>"; "<script>document.designMode='on'</script>";

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

@ -53,21 +53,16 @@ function test() {
[ "value29", "value30" ], [ "value29", "value30" ],
[ "", "value33" ] [ "", "value33" ]
]; ];
let testTabCount = 0;
let callback = function() {
testTabCount--;
if (testTabCount == 0) {
finish();
}
};
let promises = [];
for (let i = 0; i < formData.length; i++) { for (let i = 0; i < formData.length; i++) {
testTabCount++; promises.push(testTabRestoreData(formData[i], expectedValues[i]));
testTabRestoreData(formData[i], expectedValues[i], callback);
} }
Promise.all(promises).then(() => finish(), ex => ok(false, ex));
} }
function testTabRestoreData(aFormData, aExpectedValue, aCallback) { async function testTabRestoreData(aFormData, aExpectedValue) {
let URL = ROOT + "browser_formdata_format_sample.html"; let URL = ROOT + "browser_formdata_format_sample.html";
let tab = gBrowser.addTab("about:blank"); let tab = gBrowser.addTab("about:blank");
let browser = tab.linkedBrowser; let browser = tab.linkedBrowser;
@ -75,39 +70,35 @@ function testTabRestoreData(aFormData, aExpectedValue, aCallback) {
aFormData.url = URL; aFormData.url = URL;
let tabState = { entries: [{ url: URL }], formdata: aFormData }; let tabState = { entries: [{ url: URL }], formdata: aFormData };
Task.spawn(function () { await promiseBrowserLoaded(tab.linkedBrowser);
yield promiseBrowserLoaded(tab.linkedBrowser); await promiseTabState(tab, tabState);
yield promiseTabState(tab, tabState);
yield TabStateFlusher.flush(tab.linkedBrowser); await TabStateFlusher.flush(tab.linkedBrowser);
let restoredTabState = JSON.parse(ss.getTabState(tab)); let restoredTabState = JSON.parse(ss.getTabState(tab));
let restoredFormData = restoredTabState.formdata; let restoredFormData = restoredTabState.formdata;
if (restoredFormData) { if (restoredFormData) {
let doc = tab.linkedBrowser.contentDocument; let doc = tab.linkedBrowser.contentDocument;
let input1 = doc.getElementById("input1"); let input1 = doc.getElementById("input1");
let input2 = doc.querySelector("input[name=input2]"); let input2 = doc.querySelector("input[name=input2]");
// test format // test format
ok("id" in restoredFormData || "xpath" in restoredFormData, ok("id" in restoredFormData || "xpath" in restoredFormData,
"FormData format is valid: " + restoredFormData); "FormData format is valid: " + restoredFormData);
// validate that there are no old keys // validate that there are no old keys
for (let key of Object.keys(restoredFormData)) { for (let key of Object.keys(restoredFormData)) {
if (["id", "xpath", "url"].indexOf(key) === -1) { if (["id", "xpath", "url"].indexOf(key) === -1) {
ok(false, "FormData format is invalid."); ok(false, "FormData format is invalid.");
}
} }
// test id
is(input1.value, aExpectedValue[0],
"FormData by 'id' has been restored correctly");
// test xpath
is(input2.value, aExpectedValue[1],
"FormData by 'xpath' has been restored correctly");
} }
// test id
is(input1.value, aExpectedValue[0],
"FormData by 'id' has been restored correctly");
// test xpath
is(input2.value, aExpectedValue[1],
"FormData by 'xpath' has been restored correctly");
}
// clean up // clean up
gBrowser.removeTab(tab); gBrowser.removeTab(tab);
// This test might time out if the task fails.
}).then(aCallback);
} }

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

@ -38,7 +38,7 @@ const FIELDS = {
"//input[@type='file'][2]": [FILE1, FILE2] "//input[@type='file'][2]": [FILE1, FILE2]
}; };
add_task(function test_form_data_restoration() { add_task(function* test_form_data_restoration() {
// Load page with some input fields. // Load page with some input fields.
let tab = gBrowser.addTab(URL); let tab = gBrowser.addTab(URL);
let browser = tab.linkedBrowser; let browser = tab.linkedBrowser;

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

@ -8,7 +8,7 @@
*/ */
// Loading a toplevel frameset // Loading a toplevel frameset
add_task(function() { add_task(function*() {
let testURL = getRootDirectory(gTestPath) + "browser_frame_history_index.html"; let testURL = getRootDirectory(gTestPath) + "browser_frame_history_index.html";
let tab = gBrowser.addTab(testURL); let tab = gBrowser.addTab(testURL);
gBrowser.selectedTab = tab; gBrowser.selectedTab = tab;
@ -51,7 +51,7 @@ add_task(function() {
}); });
// Loading the frameset inside an iframe // Loading the frameset inside an iframe
add_task(function() { add_task(function*() {
let testURL = getRootDirectory(gTestPath) + "browser_frame_history_index2.html"; let testURL = getRootDirectory(gTestPath) + "browser_frame_history_index2.html";
let tab = gBrowser.addTab(testURL); let tab = gBrowser.addTab(testURL);
gBrowser.selectedTab = tab; gBrowser.selectedTab = tab;
@ -98,7 +98,7 @@ add_task(function() {
}); });
// Now, test that we don't record history if the iframe is added dynamically // Now, test that we don't record history if the iframe is added dynamically
add_task(function() { add_task(function*() {
// Start with an empty history // Start with an empty history
let blankState = JSON.stringify({ let blankState = JSON.stringify({
windows: [{ windows: [{

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

@ -13,7 +13,7 @@ const URL_FRAMESET = HTTPROOT + "browser_frametree_sample_frameset.html";
* when a page starts loading and we also expect a valid frame tree to exist * when a page starts loading and we also expect a valid frame tree to exist
* when it has stopped loading. * when it has stopped loading.
*/ */
add_task(function test_frametree() { add_task(function* test_frametree() {
const FRAME_TREE_SINGLE = { href: URL }; const FRAME_TREE_SINGLE = { href: URL };
const FRAME_TREE_FRAMESET = { const FRAME_TREE_FRAMESET = {
href: URL_FRAMESET, href: URL_FRAMESET,
@ -65,7 +65,7 @@ add_task(function test_frametree() {
* after the load event. SessionStore can't handle these and will not restore * after the load event. SessionStore can't handle these and will not restore
* or collect any data for them. * or collect any data for them.
*/ */
add_task(function test_frametree_dynamic() { add_task(function* test_frametree_dynamic() {
// The frame tree as expected. The first two frames are static // The frame tree as expected. The first two frames are static
// and the third one was created on DOMContentLoaded. // and the third one was created on DOMContentLoaded.
const FRAME_TREE = { const FRAME_TREE = {

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

@ -7,7 +7,7 @@
* Ensure that history entries that should not be persisted are restored in the * Ensure that history entries that should not be persisted are restored in the
* same state. * same state.
*/ */
add_task(function check_history_not_persisted() { add_task(function* check_history_not_persisted() {
// Create an about:blank tab // Create an about:blank tab
let tab = gBrowser.addTab("about:blank"); let tab = gBrowser.addTab("about:blank");
let browser = tab.linkedBrowser; let browser = tab.linkedBrowser;
@ -44,7 +44,7 @@ add_task(function check_history_not_persisted() {
* Check that entries default to being persisted when the attribute doesn't * Check that entries default to being persisted when the attribute doesn't
* exist * exist
*/ */
add_task(function check_history_default_persisted() { add_task(function* check_history_default_persisted() {
// Create an about:blank tab // Create an about:blank tab
let tab = gBrowser.addTab("about:blank"); let tab = gBrowser.addTab("about:blank");
let browser = tab.linkedBrowser; let browser = tab.linkedBrowser;

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

@ -20,7 +20,7 @@ add_task(function setup() {
/** /**
* Ensure that a pending tab has label and icon correctly set. * Ensure that a pending tab has label and icon correctly set.
*/ */
add_task(function test_label_and_icon() { add_task(function* test_label_and_icon() {
// Create a new tab. // Create a new tab.
let tab = gBrowser.addTab("about:robots"); let tab = gBrowser.addTab("about:robots");
let browser = tab.linkedBrowser; let browser = tab.linkedBrowser;

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

@ -5,7 +5,7 @@
* This test ensures that closed tabs are merged when restoring * This test ensures that closed tabs are merged when restoring
* a window state without overwriting tabs. * a window state without overwriting tabs.
*/ */
add_task(function () { add_task(function* () {
const initialState = { const initialState = {
windows: [{ windows: [{
tabs: [ tabs: [

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

@ -9,7 +9,7 @@ const URL_NESTED = getRootDirectory(gTestPath) + "browser_pageStyle_sample_neste
/** /**
* This test ensures that page style information is correctly persisted. * This test ensures that page style information is correctly persisted.
*/ */
add_task(function page_style() { add_task(function* page_style() {
let tab = gBrowser.addTab(URL); let tab = gBrowser.addTab(URL);
let browser = tab.linkedBrowser; let browser = tab.linkedBrowser;
yield promiseBrowserLoaded(browser); yield promiseBrowserLoaded(browser);
@ -53,7 +53,7 @@ add_task(function page_style() {
* This test ensures that page style notification from nested documents are * This test ensures that page style notification from nested documents are
* received and the page style is persisted correctly. * received and the page style is persisted correctly.
*/ */
add_task(function nested_page_style() { add_task(function* nested_page_style() {
let tab = gBrowser.addTab(URL_NESTED); let tab = gBrowser.addTab(URL_NESTED);
let browser = tab.linkedBrowser; let browser = tab.linkedBrowser;
yield promiseBrowserLoaded(browser); yield promiseBrowserLoaded(browser);

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

@ -8,7 +8,7 @@ add_task(function cleanup() {
} }
}); });
add_task(function() { add_task(function*() {
let URL_PUBLIC = "http://example.com/public/" + Math.random(); let URL_PUBLIC = "http://example.com/public/" + Math.random();
let URL_PRIVATE = "http://example.com/private/" + Math.random(); let URL_PRIVATE = "http://example.com/private/" + Math.random();
let tab1, tab2; let tab1, tab2;
@ -59,7 +59,7 @@ add_task(function() {
} }
}); });
add_task(function () { add_task(function* () {
const FRAME_SCRIPT = "data:," + const FRAME_SCRIPT = "data:," +
"docShell.QueryInterface%28Components.interfaces.nsILoadContext%29.usePrivateBrowsing%3Dtrue"; "docShell.QueryInterface%28Components.interfaces.nsILoadContext%29.usePrivateBrowsing%3Dtrue";
@ -101,7 +101,7 @@ add_task(function () {
is(ss.getClosedWindowCount(), 0, "no windows to restore"); is(ss.getClosedWindowCount(), 0, "no windows to restore");
}); });
add_task(function () { add_task(function* () {
// Clear the list of closed windows. // Clear the list of closed windows.
forgetClosedWindows(); forgetClosedWindows();

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

@ -6,7 +6,7 @@ const TARGET = BASE + "restore_redirect_target.html";
/** /**
* Ensure that a http redirect leaves a working tab. * Ensure that a http redirect leaves a working tab.
*/ */
add_task(function check_http_redirect() { add_task(function* check_http_redirect() {
let state = { let state = {
entries: [{ url: BASE + "restore_redirect_http.html" }] entries: [{ url: BASE + "restore_redirect_http.html" }]
}; };
@ -32,7 +32,7 @@ add_task(function check_http_redirect() {
/** /**
* Ensure that a js redirect leaves a working tab. * Ensure that a js redirect leaves a working tab.
*/ */
add_task(function check_js_redirect() { add_task(function* check_js_redirect() {
let state = { let state = {
entries: [{ url: BASE + "restore_redirect_js.html" }] entries: [{ url: BASE + "restore_redirect_js.html" }]
}; };

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

@ -22,7 +22,7 @@ requestLongerTimeout(2);
* This test ensures that we properly serialize and restore scroll positions * This test ensures that we properly serialize and restore scroll positions
* for an average page without any frames. * for an average page without any frames.
*/ */
add_task(function test_scroll() { add_task(function* test_scroll() {
let tab = gBrowser.addTab(URL); let tab = gBrowser.addTab(URL);
let browser = tab.linkedBrowser; let browser = tab.linkedBrowser;
yield promiseBrowserLoaded(browser); yield promiseBrowserLoaded(browser);
@ -65,7 +65,7 @@ add_task(function test_scroll() {
* This tests ensures that we properly serialize and restore scroll positions * This tests ensures that we properly serialize and restore scroll positions
* for multiple frames of pages with framesets. * for multiple frames of pages with framesets.
*/ */
add_task(function test_scroll_nested() { add_task(function* test_scroll_nested() {
let tab = gBrowser.addTab(URL_FRAMESET); let tab = gBrowser.addTab(URL_FRAMESET);
let browser = tab.linkedBrowser; let browser = tab.linkedBrowser;
yield promiseBrowserLoaded(browser); yield promiseBrowserLoaded(browser);
@ -109,7 +109,7 @@ add_task(function test_scroll_nested() {
* Test that scroll positions persist after restoring background tabs in * Test that scroll positions persist after restoring background tabs in
* a restored window (bug 1228518). * a restored window (bug 1228518).
*/ */
add_task(function test_scroll_background_tabs() { add_task(function* test_scroll_background_tabs() {
pushPrefs(["browser.sessionstore.restore_on_demand", true]); pushPrefs(["browser.sessionstore.restore_on_demand", true]);
let newWin = yield BrowserTestUtils.openNewBrowserWindow(); let newWin = yield BrowserTestUtils.openNewBrowserWindow();

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

@ -17,7 +17,7 @@ requestLongerTimeout(2);
* Test that scroll positions of about reader page after restoring background * Test that scroll positions of about reader page after restoring background
* tabs in a restored window (bug 1153393). * tabs in a restored window (bug 1153393).
*/ */
add_task(function test_scroll_background_about_reader_tabs() { add_task(function* test_scroll_background_about_reader_tabs() {
pushPrefs(["browser.sessionstore.restore_on_demand", true]); pushPrefs(["browser.sessionstore.restore_on_demand", true]);
let newWin = yield BrowserTestUtils.openNewBrowserWindow(); let newWin = yield BrowserTestUtils.openNewBrowserWindow();

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

@ -8,7 +8,7 @@ requestLongerTimeout(2);
/** /**
* Ensure that starting a load invalidates shistory. * Ensure that starting a load invalidates shistory.
*/ */
add_task(function test_load_start() { add_task(function* test_load_start() {
// Create a new tab. // Create a new tab.
let tab = gBrowser.addTab("about:blank"); let tab = gBrowser.addTab("about:blank");
let browser = tab.linkedBrowser; let browser = tab.linkedBrowser;
@ -36,7 +36,7 @@ add_task(function test_load_start() {
/** /**
* Ensure that anchor navigation invalidates shistory. * Ensure that anchor navigation invalidates shistory.
*/ */
add_task(function test_hashchange() { add_task(function* test_hashchange() {
const URL = "data:text/html;charset=utf-8,<a id=a href=%23>clickme</a>"; const URL = "data:text/html;charset=utf-8,<a id=a href=%23>clickme</a>";
// Create a new tab. // Create a new tab.
@ -65,7 +65,7 @@ add_task(function test_hashchange() {
/** /**
* Ensure that loading pages from the bfcache invalidates shistory. * Ensure that loading pages from the bfcache invalidates shistory.
*/ */
add_task(function test_pageshow() { add_task(function* test_pageshow() {
const URL = "data:text/html;charset=utf-8,<h1>first</h1>"; const URL = "data:text/html;charset=utf-8,<h1>first</h1>";
const URL2 = "data:text/html;charset=utf-8,<h1>second</h1>"; const URL2 = "data:text/html;charset=utf-8,<h1>second</h1>";
@ -95,7 +95,7 @@ add_task(function test_pageshow() {
/** /**
* Ensure that subframe navigation invalidates shistory. * Ensure that subframe navigation invalidates shistory.
*/ */
add_task(function test_subframes() { add_task(function* test_subframes() {
const URL = "data:text/html;charset=utf-8," + const URL = "data:text/html;charset=utf-8," +
"<iframe src=http%3A//example.com/ name=t></iframe>" + "<iframe src=http%3A//example.com/ name=t></iframe>" +
"<a id=a1 href=http%3A//example.com/1 target=t>clickme</a>" + "<a id=a1 href=http%3A//example.com/1 target=t>clickme</a>" +
@ -143,7 +143,7 @@ add_task(function test_subframes() {
/** /**
* Ensure that navigating from an about page invalidates shistory. * Ensure that navigating from an about page invalidates shistory.
*/ */
add_task(function test_about_page_navigate() { add_task(function* test_about_page_navigate() {
// Create a new tab. // Create a new tab.
let tab = gBrowser.addTab("about:blank"); let tab = gBrowser.addTab("about:blank");
let browser = tab.linkedBrowser; let browser = tab.linkedBrowser;
@ -171,7 +171,7 @@ add_task(function test_about_page_navigate() {
/** /**
* Ensure that history.pushState and history.replaceState invalidate shistory. * Ensure that history.pushState and history.replaceState invalidate shistory.
*/ */
add_task(function test_pushstate_replacestate() { add_task(function* test_pushstate_replacestate() {
// Create a new tab. // Create a new tab.
let tab = gBrowser.addTab("http://example.com/1"); let tab = gBrowser.addTab("http://example.com/1");
let browser = tab.linkedBrowser; let browser = tab.linkedBrowser;
@ -210,7 +210,7 @@ add_task(function test_pushstate_replacestate() {
/** /**
* Ensure that slow loading subframes will invalidate shistory. * Ensure that slow loading subframes will invalidate shistory.
*/ */
add_task(function test_slow_subframe_load() { add_task(function* test_slow_subframe_load() {
const SLOW_URL = "http://mochi.test:8888/browser/browser/components/" + const SLOW_URL = "http://mochi.test:8888/browser/browser/components/" +
"sessionstore/test/browser_sessionHistory_slow.sjs"; "sessionstore/test/browser_sessionHistory_slow.sjs";

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

@ -15,7 +15,7 @@ const INNER_VALUE = "inner-value-" + RAND;
* This test ensures that setting, modifying and restoring sessionStorage data * This test ensures that setting, modifying and restoring sessionStorage data
* works as expected. * works as expected.
*/ */
add_task(function session_storage() { add_task(function* session_storage() {
let tab = gBrowser.addTab(URL); let tab = gBrowser.addTab(URL);
let browser = tab.linkedBrowser; let browser = tab.linkedBrowser;
yield promiseBrowserLoaded(browser); yield promiseBrowserLoaded(browser);
@ -102,7 +102,7 @@ add_task(function session_storage() {
* This test ensures that purging domain data also purges data from the * This test ensures that purging domain data also purges data from the
* sessionStorage data collected for tabs. * sessionStorage data collected for tabs.
*/ */
add_task(function purge_domain() { add_task(function* purge_domain() {
let tab = gBrowser.addTab(URL); let tab = gBrowser.addTab(URL);
let browser = tab.linkedBrowser; let browser = tab.linkedBrowser;
yield promiseBrowserLoaded(browser); yield promiseBrowserLoaded(browser);
@ -126,7 +126,7 @@ add_task(function purge_domain() {
* This test ensures that collecting sessionStorage data respects the privacy * This test ensures that collecting sessionStorage data respects the privacy
* levels as set by the user. * levels as set by the user.
*/ */
add_task(function respect_privacy_level() { add_task(function* respect_privacy_level() {
let tab = gBrowser.addTab(URL + "&secure"); let tab = gBrowser.addTab(URL + "&secure");
yield promiseBrowserLoaded(tab.linkedBrowser); yield promiseBrowserLoaded(tab.linkedBrowser);
yield promiseRemoveTab(tab); yield promiseRemoveTab(tab);