Bug 305085 - add a test for beforeunload uses, r=jaws

--HG--
extra : rebase_source : 56f5d53be23a811d9a5eeec68a089824f538942b
extra : histedit_source : af42dfab71d3c56a54ff337b0c02e05dde856572
This commit is contained in:
Gijs Kruitbosch 2014-12-19 21:41:57 +00:00
Родитель 9ebe70267b
Коммит 9d67d39aaf
3 изменённых файлов: 47 добавлений и 1 удалений

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

@ -124,6 +124,8 @@ skip-if = e10s # Bug 1101993 - times out for unknown reasons when run in the dir
[browser_autocomplete_oldschool_wrap.js]
[browser_backButtonFitts.js]
skip-if = os != "win" || e10s # The Fitts Law back button is only supported on Windows (bug 571454) / e10s - Bug 1099154: test touches content (attempts to add an event listener directly to the contentWindow)
[browser_beforeunload_duplicate_dialogs.js]
skip-if = e10s # bug 967873 means permitUnload doesn't work in e10s mode
[browser_blob-channelname.js]
[browser_bookmark_titles.js]
skip-if = buildapp == 'mulet' || toolkit == "windows" || e10s # Disabled on Windows due to frequent failures (bugs 825739, 841341) / e10s - Bug 1094205 - places doesn't return the right thing in e10s mode, for some reason

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

@ -0,0 +1,44 @@
const TEST_PAGE = "http://mochi.test:8888/browser/browser/base/content/test/general/file_double_close_tab.html";
let expectingDialog = false;
function onTabModalDialogLoaded(node) {
ok(expectingDialog, "Should be expecting this dialog.");
expectingDialog = false;
// This accepts the dialog, closing it
node.Dialog.ui.button0.click();
}
// Listen for the dialog being created
Services.obs.addObserver(onTabModalDialogLoaded, "tabmodal-dialog-loaded", false);
registerCleanupFunction(() => {
Services.prefs.clearUserPref("browser.tabs.warnOnClose");
Services.obs.removeObserver(onTabModalDialogLoaded, "tabmodal-dialog-loaded");
});
add_task(function* closeLastTabInWindow() {
let newWin = yield promiseOpenAndLoadWindow({}, true);
let firstTab = newWin.gBrowser.selectedTab;
yield promiseTabLoadEvent(firstTab, TEST_PAGE);
let windowClosedPromise = promiseWindowClosed(newWin);
expectingDialog = true;
// close tab:
document.getAnonymousElementByAttribute(firstTab, "anonid", "close-button").click();
yield windowClosedPromise;
ok(!expectingDialog, "There should have been a dialog.");
ok(newWin.closed, "Window should be closed.");
});
add_task(function* closeWindowWithMultipleTabsIncludingOneBeforeUnload() {
Services.prefs.setBoolPref("browser.tabs.warnOnClose", false);
let newWin = yield promiseOpenAndLoadWindow({}, true);
let firstTab = newWin.gBrowser.selectedTab;
yield promiseTabLoadEvent(firstTab, TEST_PAGE);
yield promiseTabLoadEvent(newWin.gBrowser.addTab(), "http://example.com/");
let windowClosedPromise = promiseWindowClosed(newWin);
expectingDialog = true;
newWin.BrowserTryToCloseWindow();
yield windowClosedPromise;
ok(!expectingDialog, "There should have been a dialog.");
ok(newWin.closed, "Window should be closed.");
});

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

@ -2,7 +2,7 @@
<html>
<head>
<meta charset="utf-8">
<title>Test for bug 1050638 - clicking tab close button twice should close tab even in beforeunload case</title>
<title>Test page that blocks beforeunload. Used in tests for bug 1050638 and bug 305085</title>
</head>
<body>
This page will block beforeunload. It should still be user-closable at all times.