mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-27 14:52:16 +00:00
Bug 1753608 - Fix Session Restore fails to restore some features. r=Gijs
* I overlooked that some `window.open` feature names are different from barprop names. * Adding "resizable" will regress the maximize button prblem. But it was broken even before bug 1564738 and fixing it requires changes to session data. The current session data do not contain enough information to restore the maximize button state correctly. I'll file a follow-up bug about this. * I renamed the test file because it is no longer limited to tab visibility. Differential Revision: https://phabricator.services.mozilla.com/D137838
This commit is contained in:
parent
9be4ef33b4
commit
f7542880f9
@ -123,7 +123,6 @@ skip-if =
|
||||
[browser_tab_label_picture_in_picture.js]
|
||||
[browser_tab_manager_visibility.js]
|
||||
[browser_tab_move_to_new_window_reload.js]
|
||||
[browser_tabbar_visibility.js]
|
||||
[browser_tabCloseProbes.js]
|
||||
[browser_tabContextMenu_keyboard.js]
|
||||
[browser_tabReorder_overflow.js]
|
||||
|
@ -1,49 +0,0 @@
|
||||
/* Any copyright is dedicated to the Public Domain.
|
||||
* http://creativecommons.org/publicdomain/zero/1.0/ */
|
||||
|
||||
"use strict";
|
||||
|
||||
function testFeatures(win) {
|
||||
is(win.toolbar.visible, false, "toolbar should be hidden");
|
||||
let toolbar = win.document.getElementById("TabsToolbar");
|
||||
is(toolbar.collapsed, true, "tabbar should be collapsed");
|
||||
let chromeFlags = win.docShell.treeOwner
|
||||
.QueryInterface(Ci.nsIInterfaceRequestor)
|
||||
.getInterface(Ci.nsIAppWindow).chromeFlags;
|
||||
is(
|
||||
chromeFlags & Ci.nsIWebBrowserChrome.CHROME_WINDOW_RESIZE,
|
||||
0,
|
||||
"window shouls not be resizable"
|
||||
);
|
||||
}
|
||||
|
||||
add_task(async function testWindowOpen() {
|
||||
const DUMMY_PAGE = "browser/base/content/test/tabs/dummy_page.html";
|
||||
const TEST_URL = "http://example.com/browser/" + DUMMY_PAGE;
|
||||
const TEST_URL_CHROME = "chrome://mochitests/content/browser/" + DUMMY_PAGE;
|
||||
|
||||
BrowserTestUtils.loadURI(gBrowser.selectedBrowser, TEST_URL_CHROME);
|
||||
await BrowserTestUtils.browserLoaded(gBrowser.selectedBrowser);
|
||||
|
||||
let newWindowPromise = BrowserTestUtils.waitForNewWindow({
|
||||
url: TEST_URL,
|
||||
});
|
||||
await SpecialPowers.spawn(gBrowser.selectedBrowser, [TEST_URL], url => {
|
||||
content.eval(`window.open("${url}", "_blank", "menubar=0")`);
|
||||
});
|
||||
let win = await newWindowPromise;
|
||||
|
||||
testFeatures(win);
|
||||
|
||||
await BrowserTestUtils.closeWindow(win);
|
||||
|
||||
newWindowPromise = BrowserTestUtils.waitForNewWindow({
|
||||
url: TEST_URL,
|
||||
});
|
||||
SessionStore.undoCloseWindow(0);
|
||||
win = await newWindowPromise;
|
||||
|
||||
testFeatures(win);
|
||||
|
||||
await BrowserTestUtils.closeWindow(win);
|
||||
});
|
@ -76,6 +76,11 @@ const WINDOW_HIDEABLE_FEATURES = [
|
||||
"scrollbars",
|
||||
];
|
||||
|
||||
const WINDOW_OPEN_FEATURES_MAP = {
|
||||
locationbar: "location",
|
||||
statusbar: "status",
|
||||
};
|
||||
|
||||
// Messages that will be received via the Frame Message Manager.
|
||||
const MESSAGES = [
|
||||
// The content script sends us data that has been invalidated and needs to
|
||||
@ -5147,11 +5152,12 @@ var SessionStoreInternal = {
|
||||
if (!hidden.length) {
|
||||
features.push("all");
|
||||
} else {
|
||||
features.push(
|
||||
...WINDOW_HIDEABLE_FEATURES.filter(aFeature => {
|
||||
return !hidden.includes(aFeature);
|
||||
})
|
||||
);
|
||||
features.push("resizable");
|
||||
WINDOW_HIDEABLE_FEATURES.forEach(aFeature => {
|
||||
if (!hidden.includes(aFeature)) {
|
||||
features.push(WINDOW_OPEN_FEATURES_MAP[aFeature] || aFeature);
|
||||
}
|
||||
});
|
||||
}
|
||||
WINDOW_ATTRIBUTES.forEach(aFeature => {
|
||||
// Use !isNaN as an easy way to ignore sizemode and check for numbers
|
||||
|
@ -104,6 +104,7 @@ skip-if =
|
||||
skip-if = debug || ccov # Bug 1625525
|
||||
[browser_restore_srcdoc.js]
|
||||
[browser_restore_tabless_window.js]
|
||||
[browser_restored_window_features.js]
|
||||
[browser_unrestored_crashedTabs.js]
|
||||
skip-if =
|
||||
!e10s || !crashreporter
|
||||
|
@ -0,0 +1,71 @@
|
||||
/* Any copyright is dedicated to the Public Domain.
|
||||
* http://creativecommons.org/publicdomain/zero/1.0/ */
|
||||
|
||||
"use strict";
|
||||
|
||||
function testFeatures(win, barprops) {
|
||||
for (let [name, visible] of Object.entries(barprops)) {
|
||||
is(
|
||||
win[name].visible,
|
||||
visible,
|
||||
name + " should be " + (visible ? "visible" : "hidden")
|
||||
);
|
||||
}
|
||||
is(win.toolbar.visible, false, "toolbar should be hidden");
|
||||
let toolbar = win.document.getElementById("TabsToolbar");
|
||||
is(toolbar.collapsed, true, "tabbar should be collapsed");
|
||||
let chromeFlags = win.docShell.treeOwner
|
||||
.QueryInterface(Ci.nsIInterfaceRequestor)
|
||||
.getInterface(Ci.nsIAppWindow).chromeFlags;
|
||||
is(
|
||||
chromeFlags & Ci.nsIWebBrowserChrome.CHROME_WINDOW_RESIZE,
|
||||
Ci.nsIWebBrowserChrome.CHROME_WINDOW_RESIZE,
|
||||
"window should be resizable"
|
||||
);
|
||||
}
|
||||
|
||||
add_task(async function testRestoredWindowFeatures() {
|
||||
const DUMMY_PAGE = "browser/base/content/test/tabs/dummy_page.html";
|
||||
const TESTS = [
|
||||
{
|
||||
url: "http://example.com/browser/" + DUMMY_PAGE,
|
||||
features: "menubar=0,resizable",
|
||||
barprops: { menubar: false },
|
||||
},
|
||||
{
|
||||
url: "data:,", // title should be empty
|
||||
features: "location,resizable",
|
||||
barprops: { locationbar: true },
|
||||
},
|
||||
];
|
||||
const TEST_URL_CHROME = "chrome://mochitests/content/browser/" + DUMMY_PAGE;
|
||||
|
||||
for (let test of TESTS) {
|
||||
BrowserTestUtils.loadURI(gBrowser.selectedBrowser, TEST_URL_CHROME);
|
||||
await BrowserTestUtils.browserLoaded(gBrowser.selectedBrowser);
|
||||
|
||||
let newWindowPromise = BrowserTestUtils.waitForNewWindow({
|
||||
url: test.url,
|
||||
});
|
||||
await SpecialPowers.spawn(gBrowser.selectedBrowser, [test], t => {
|
||||
content.eval(`window.open("${t.url}", "_blank", "${t.features}")`);
|
||||
});
|
||||
let win = await newWindowPromise;
|
||||
let title = win.document.title;
|
||||
|
||||
testFeatures(win, test.barprops);
|
||||
|
||||
await BrowserTestUtils.closeWindow(win);
|
||||
|
||||
newWindowPromise = BrowserTestUtils.waitForNewWindow({
|
||||
url: test.url,
|
||||
});
|
||||
SessionStore.undoCloseWindow(0);
|
||||
win = await newWindowPromise;
|
||||
|
||||
is(title, win.document.title, "title should be preserved");
|
||||
testFeatures(win, test.barprops);
|
||||
|
||||
await BrowserTestUtils.closeWindow(win);
|
||||
}
|
||||
});
|
Loading…
Reference in New Issue
Block a user