Merge mozilla-central to autoland. a=merge

This commit is contained in:
Narcis Beleuzu 2018-08-30 16:08:00 +03:00
Родитель 055f6b25a3 a4ec006bb0
Коммит 78f15dbb01
13 изменённых файлов: 89 добавлений и 74 удалений

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

@ -14,27 +14,28 @@ function caretMoveChecker(target, caretOffset) {
}
async function checkURLBarCaretEvents() {
const kURL = "about:mozilla";
let newWin = await BrowserTestUtils.openNewBrowserWindow();
newWin.gBrowser.selectedBrowser.loadURI(kURL);
let url = "about:mozilla";
await waitForEvent(
let onDocLoad = waitForEvent(
EVENT_DOCUMENT_LOAD_COMPLETE,
event => {
try {
return event.accessible.QueryInterface(nsIAccessibleDocument).URL == kURL;
return event.accessible.QueryInterface(nsIAccessibleDocument).URL == url;
} catch (e) {
return false;
}
}
);
info("Loaded " + kURL);
let [ newWin ] = await Promise.all([
BrowserTestUtils.openNewBrowserWindow({ url }),
onDocLoad
]);
let urlbarInputEl = newWin.document.getElementById("urlbar").inputField;
let urlbarInput = getAccessible(urlbarInputEl, [ nsIAccessibleText ]);
let onCaretMove = waitForEvents([
[ EVENT_TEXT_CARET_MOVED, caretMoveChecker(urlbarInput, kURL.length) ],
[ EVENT_TEXT_CARET_MOVED, caretMoveChecker(urlbarInput, url.length) ],
[ EVENT_FOCUS, urlbarInput ]
]);

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

@ -113,12 +113,6 @@ var CaptivePortalWatcher = {
}
let win = BrowserWindowTracker.getTopWindow();
// Used by tests: ignore the main test window in order to enable testing of
// the case where we have no open windows.
if (win && win.document.documentElement.getAttribute("ignorecaptiveportal")) {
win = null;
}
// If no browser window has focus, open and show the tab when we regain focus.
// This is so that if a different application was focused, when the user
// (re-)focuses a browser window, we open the tab immediately in that window
@ -142,12 +136,6 @@ var CaptivePortalWatcher = {
}
let win = BrowserWindowTracker.getTopWindow();
// Used by tests: ignore the main test window in order to enable testing of
// the case where we have no open windows.
if (win && win.document.documentElement.getAttribute("ignorecaptiveportal")) {
win = null;
}
if (win != Services.ww.activeWindow) {
// The window that got focused was not a browser window.
return;

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

@ -4290,19 +4290,6 @@ function toOpenWindowByType(inType, uri, features) {
window.open(uri, "_blank", "chrome,extrachrome,menubar,resizable,scrollbars,status,toolbar");
}
/**
* Open a new browser window.
*
* @param {Object} options
* {
* private: A boolean indicating if the window should be
* private
* remote: A boolean indicating if the window should run
* remote browser tabs or not. If omitted, the window
* will choose the profile default state.
* }
* @return a reference to the new window.
*/
function OpenBrowserWindow(options) {
var telemetryObj = {};
TelemetryStopwatch.start("FX_NEW_WINDOW_MS", telemetryObj);

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

@ -20,13 +20,22 @@ async function setupPrefsAndRecentWindowBehavior() {
// We need to test behavior when a portal is detected when there is no browser
// window, but we can't close the default window opened by the test harness.
// Instead, we deactivate CaptivePortalWatcher in the default window and
// exclude it using an attribute to mask its presence.
// exclude it from BrowserWindowTracker.getTopWindow in an attempt to
// mask its presence.
window.CaptivePortalWatcher.uninit();
window.document.documentElement.setAttribute("ignorecaptiveportal", "true");
let getTopWindowCopy = BrowserWindowTracker.getTopWindow;
let defaultWindow = window;
BrowserWindowTracker.getTopWindow = () => {
let win = getTopWindowCopy();
if (win == defaultWindow) {
return null;
}
return win;
};
registerCleanupFunction(function cleanUp() {
BrowserWindowTracker.getTopWindow = getTopWindowCopy;
window.CaptivePortalWatcher.init();
window.document.documentElement.removeAttribute("ignorecaptiveportal");
});
}

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

@ -590,24 +590,18 @@ add_task(async function test_large_popup() {
// This test checks the same as the previous test but in a new smaller window.
add_task(async function test_large_popup_in_small_window() {
let newWin = await BrowserTestUtils.openNewBrowserWindow();
let resizePromise = BrowserTestUtils.waitForEvent(newWin, "resize", false, e => {
return newWin.innerHeight <= 400 && newWin.innerWidth <= 400;
});
newWin.resizeTo(400, 400);
await resizePromise;
let newwin = await BrowserTestUtils.openNewBrowserWindow({ width: 400, height: 400 });
const pageUrl = "data:text/html," + escape(PAGECONTENT_SMALL);
let browserLoadedPromise = BrowserTestUtils.browserLoaded(newWin.gBrowser.selectedBrowser);
await BrowserTestUtils.loadURI(newWin.gBrowser.selectedBrowser, pageUrl);
let browserLoadedPromise = BrowserTestUtils.browserLoaded(newwin.gBrowser.selectedBrowser);
await BrowserTestUtils.loadURI(newwin.gBrowser.selectedBrowser, pageUrl);
await browserLoadedPromise;
newWin.gBrowser.selectedBrowser.focus();
newwin.gBrowser.selectedBrowser.focus();
await performLargePopupTests(newWin);
await performLargePopupTests(newwin);
await BrowserTestUtils.closeWindow(newWin);
await BrowserTestUtils.closeWindow(newwin);
});
async function performSelectSearchTests(win) {

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

@ -26,8 +26,7 @@ let createPrivateWindow = async function createPrivateWindow(url) {
gPrivateBrowser = gPrivateWindow.getBrowser().selectedBrowser;
BrowserTestUtils.loadURI(gPrivateBrowser, url);
await BrowserTestUtils.browserLoaded(gPrivateBrowser, false, url);
info("loaded " + url);
await BrowserTestUtils.browserLoaded(gPrivateBrowser);
};
add_task(async function test() {

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

@ -19,11 +19,11 @@ add_task(async function testAdoptedTwoWindows() {
// being adopted from the main window which doesn't have a shown sidebar. See Bug 1407737.
info("Ensure that sidebar state is adopted only from the opener");
let win1 = await BrowserTestUtils.openNewBrowserWindow();
let win1 = await BrowserTestUtils.openNewBrowserWindow({opener: window});
await win1.SidebarUI.show("viewBookmarksSidebar");
await BrowserTestUtils.closeWindow(win1);
let win2 = await BrowserTestUtils.openNewBrowserWindow();
let win2 = await BrowserTestUtils.openNewBrowserWindow({opener: window});
ok(!win2.document.getElementById("sidebar-button").hasAttribute("checked"), "Sidebar button isn't checked");
ok(!win2.SidebarUI.isOpen, "Sidebar is closed");
await BrowserTestUtils.closeWindow(win2);
@ -46,7 +46,7 @@ add_task(async function testEventReceivedInNewWindow() {
info("Opening a new window and expecting the SidebarFocused event to not fire");
let promiseNewWindow = BrowserTestUtils.waitForNewWindow();
BrowserTestUtils.openNewBrowserWindow();
BrowserTestUtils.openNewBrowserWindow({opener: window});
let win = await promiseNewWindow;
let adoptedShown = BrowserTestUtils.waitForEvent(win, "SidebarShown");

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

@ -42,7 +42,7 @@ add_task(async function() {
is(SidebarUI.currentID, "viewHistorySidebar", "Selected sidebar remembered");
await hideSidebar();
let otherWin = await BrowserTestUtils.openNewBrowserWindow();
let otherWin = await BrowserTestUtils.openNewBrowserWindow({opener: window});
await showSidebar(otherWin);
is(otherWin.SidebarUI.currentID, "viewHistorySidebar", "Selected sidebar remembered across windows");
await hideSidebar(otherWin);

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

@ -48,7 +48,7 @@ add_task(async function sidebar_windows() {
// SidebarUI relies on window.opener being set, which is normal behavior when
// using menu or key commands to open a new browser window.
let win = await BrowserTestUtils.openNewBrowserWindow();
let win = await BrowserTestUtils.openNewBrowserWindow({opener: window});
await secondSidebar;
ok(!win.document.getElementById("sidebar-box").hidden, "sidebar box is visible in second window");

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

@ -17,7 +17,8 @@ function promiseTestOpenCloseWindow(aIsPrivate, aTest) {
return (async function() {
let win = await BrowserTestUtils.openNewBrowserWindow({ "private": aIsPrivate });
win.gBrowser.selectedBrowser.loadURI(aTest.url);
await promiseBrowserLoaded(win.gBrowser.selectedBrowser, true, aTest.url);
await promiseBrowserLoaded(win.gBrowser.selectedBrowser);
await Promise.resolve();
// Mark the window with some unique data to be restored later on.
ss.setWindowValue(win, aTest.key, aTest.value);
await TabStateFlusher.flushWindow(win);

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

@ -43,16 +43,12 @@ async function waitContentVisibilityChange(aIsHidden, aBrowser) {
*/
add_task(async function() {
info("creating test window");
let winTest = await BrowserTestUtils.openNewBrowserWindow();
// Specify the width, height, left and top, so that the new window can be
// fully covered by "window".
let resizePromise = BrowserTestUtils.waitForEvent(winTest, "resize", false, e => {
return winTest.innerHeight <= 500 && winTest.innerWidth <= 500;
});
winTest.moveTo(200, 200);
winTest.resizeTo(500, 500);
await resizePromise;
let winTest = await BrowserTestUtils.openNewBrowserWindow({ width: 500,
height: 500,
left: 200,
top: 200 });
let browserTest = winTest.gBrowser;
info(`loading test page: ${testPageURL}`);

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

@ -373,3 +373,4 @@ skip-if = toolkit == 'android' # TIMED_OUT for android
[test_mql_event_listener_leaks.html]
[test_non_matching_sheet_media.html]
[test_use_counters.html]
skip-if = !nightly_build

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

@ -25,9 +25,6 @@ ChromeUtils.import("resource://gre/modules/Services.jsm");
ChromeUtils.import("resource://testing-common/TestUtils.jsm");
ChromeUtils.import("resource://testing-common/ContentTask.jsm");
ChromeUtils.defineModuleGetter(this, "BrowserWindowTracker",
"resource:///modules/BrowserWindowTracker.jsm");
Services
.mm
.loadFrameScript(
@ -704,19 +701,61 @@ var BrowserTestUtils = {
},
/**
* Open a new browser window from an existing one.
* This relies on OpenBrowserWindow in browser.js, and waits for the window
* to be completely loaded before resolving.
*
* @param {Object} options
* {
* private: A boolean indicating if the window should be
* private
* remote: A boolean indicating if the window should run
* remote browser tabs or not. If omitted, the window
* will choose the profile default state.
* width: Desired width of window
* height: Desired height of window
* }
* @return {Promise}
* Resolves with the new window once it is loaded.
*/
async openNewBrowserWindow(options = {}) {
let currentWin = BrowserWindowTracker.getTopWindow({private: false});
if (!currentWin) {
throw new Error("Can't open a new browser window from this helper if no non-private window is open.");
let argString = Cc["@mozilla.org/supports-string;1"].
createInstance(Ci.nsISupportsString);
argString.data = "";
let features = "chrome,dialog=no,all";
let opener = null;
if (options.opener) {
opener = options.opener;
}
let win = currentWin.OpenBrowserWindow(options);
if (options.private) {
features += ",private";
}
if (options.width) {
features += ",width=" + options.width;
}
if (options.height) {
features += ",height=" + options.height;
}
if (options.left) {
features += ",left=" + options.left;
}
if (options.top) {
features += ",top=" + options.top;
}
if (options.hasOwnProperty("remote")) {
let remoteState = options.remote ? "remote" : "non-remote";
features += `,${remoteState}`;
}
if (options.url) {
argString.data = options.url;
}
let win = Services.ww.openWindow(
opener, AppConstants.BROWSER_CHROME_URL, "_blank",
features, argString);
// Wait for browser-delayed-startup-finished notification, it indicates
// that the window has loaded completely and is ready to be used for