mirror of
https://github.com/HeyPuter/firefox.git
synced 2026-11-30 14:17:36 -10:00
127 lines
4.4 KiB
HTML
127 lines
4.4 KiB
HTML
<!DOCTYPE HTML>
|
|
<html>
|
|
<!--
|
|
https://bugzilla.mozilla.org/show_bug.cgi?id=1301160
|
|
-->
|
|
<head>
|
|
<meta charset="utf-8">
|
|
<title>Test for Bug 1301160</title>
|
|
<script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
|
|
<script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SpawnTask.js"></script>
|
|
<link rel="stylesheet" type="text/css" href="chrome://global/skin"/>
|
|
<link rel="stylesheet" type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css"/>
|
|
<script type="application/javascript" src="head.js"></script>
|
|
<script type="application/javascript">
|
|
|
|
/** Test for Bug 1301160 **/
|
|
|
|
"use strict";
|
|
|
|
const { classes: Cc, interfaces: Ci, utils: Cu } = Components;
|
|
|
|
Cu.import("resource://gre/modules/XPCOMUtils.jsm");
|
|
Cu.import("resource://gre/modules/Services.jsm");
|
|
Cu.import("resource://gre/modules/Messaging.jsm");
|
|
Cu.import("resource://gre/modules/Task.jsm");
|
|
|
|
// The chrome window and related services
|
|
let chromeWin = Services.wm.getMostRecentWindow("navigator:browser");
|
|
let BrowserApp = chromeWin.BrowserApp;
|
|
let ss = Cc["@mozilla.org/browser/sessionstore;1"].getService(Ci.nsISessionStore);
|
|
|
|
// Track the tabs where the tests are happening
|
|
let tabParent;
|
|
let tabChild1;
|
|
let tabChild2;
|
|
|
|
function cleanupTabs() {
|
|
if (tabParent) {
|
|
BrowserApp.closeTab(tabParent);
|
|
tabParent = null;
|
|
}
|
|
|
|
if (tabChild1) {
|
|
BrowserApp.closeTab(tabChild1);
|
|
tabChild1 = null;
|
|
}
|
|
|
|
if (tabChild2) {
|
|
BrowserApp.closeTab(tabChild2);
|
|
tabChild2 = null;
|
|
}
|
|
}
|
|
|
|
const url = "data:text/html;charset=utf-8,It%20was%20a%20dark%20and%20stormy%20night.";
|
|
|
|
add_task(function* test_sessionStoreParentId() {
|
|
SimpleTest.registerCleanupFunction(function() {
|
|
cleanupTabs();
|
|
});
|
|
|
|
// First, check that passing a parent tab ID works as expected
|
|
tabParent = BrowserApp.addTab(url, { selected: true });
|
|
yield promiseBrowserEvent(tabParent.browser, "DOMContentLoaded");
|
|
|
|
// Open tabs without passing a parent tab ID
|
|
tabChild1 = BrowserApp.addTab(url, { selected: false });
|
|
tabChild2 = BrowserApp.addTab(url, { selected: true });
|
|
yield promiseTabEvent(BrowserApp.deck, "TabSelect");
|
|
is(BrowserApp.selectedTab, tabChild2, "2nd child tab is selected");
|
|
|
|
// After closing that tab, its neighbour should be selected
|
|
BrowserApp.closeTab(tabChild2);
|
|
tabChild2 = null;
|
|
yield promiseTabEvent(BrowserApp.deck, "TabSelect");
|
|
is(BrowserApp.selectedTab, tabChild1, "1st child tab is selected");
|
|
|
|
// Add a new tab and pass a parent tab ID this time
|
|
tabChild2 = BrowserApp.addTab(url, { selected: true, parentId: tabParent.id });
|
|
yield promiseTabEvent(BrowserApp.deck, "TabSelect");
|
|
is(BrowserApp.selectedTab, tabChild2, "2nd child tab is selected");
|
|
|
|
// After closing that tab, its parent should be selected
|
|
BrowserApp.closeTab(tabChild2);
|
|
tabChild2 = null;
|
|
yield promiseTabEvent(BrowserApp.deck, "TabSelect");
|
|
is(BrowserApp.selectedTab, tabParent, "parent tab is selected");
|
|
|
|
// Reset selection and switch to the other child tab
|
|
BrowserApp.selectTab(tabChild1);
|
|
yield promiseTabEvent(BrowserApp.deck, "TabSelect");
|
|
is(BrowserApp.selectedTab, tabChild1, "1st child tab is selected");
|
|
|
|
// Now check that this works even if the child tab is closed and subsequently restored
|
|
tabChild2 = BrowserApp.addTab(url, { selected: false, parentId: tabParent.id });
|
|
yield promiseTabEvent(tabChild2.browser, "SSTabDataUpdated");
|
|
BrowserApp.closeTab(tabChild2);
|
|
yield promiseTabEvent(tabChild2.browser, "SSTabCloseProcessed");
|
|
|
|
// Restore the tab
|
|
let closedTabData = ss.getClosedTabs(chromeWin)[0];
|
|
let browser = ss.undoCloseTab(chromeWin, closedTabData);
|
|
yield promiseTabEvent(BrowserApp.deck, "TabSelect");
|
|
tabChild2 = BrowserApp.getTabForBrowser(browser);
|
|
is(BrowserApp.selectedTab, tabChild2, "restored 2nd child tab is selected");
|
|
|
|
// After closing that tab, its parent should be selected
|
|
BrowserApp.closeTab(tabChild2);
|
|
tabChild2 = null;
|
|
yield promiseTabEvent(BrowserApp.deck, "TabSelect");
|
|
is(BrowserApp.selectedTab, tabParent, "parent tab is selected after restoring");
|
|
|
|
cleanupTabs();
|
|
});
|
|
|
|
</script>
|
|
</head>
|
|
<body>
|
|
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=1301160">Mozilla Bug 1301160</a>
|
|
<p id="display"></p>
|
|
<div id="content" style="display: none">
|
|
|
|
</div>
|
|
<pre id="test">
|
|
</pre>
|
|
</body>
|
|
</html>
|