зеркало из https://github.com/mozilla/gecko-dev.git
Backed out 2 changesets (bug 1792466) for causing mch fails on test_mochitest_integration.py. CLOSED TREE
Backed out changeset 36cc09178d76 (bug 1792466) Backed out changeset 418d1ede2ae3 (bug 1792466)
This commit is contained in:
Родитель
3c01cd430a
Коммит
195f45e30b
|
@ -230,6 +230,7 @@ function openBrowserWindow(
|
|||
postData = null,
|
||||
forcePrivate = false
|
||||
) {
|
||||
let chromeURL = AppConstants.BROWSER_CHROME_URL;
|
||||
const isStartup =
|
||||
cmdLine && cmdLine.state == Ci.nsICommandLine.STATE_INITIAL_LAUNCH;
|
||||
|
||||
|
@ -316,11 +317,10 @@ function openBrowserWindow(
|
|||
}
|
||||
|
||||
let openTime = win.openTime;
|
||||
win.location = AppConstants.BROWSER_CHROME_URL;
|
||||
win.location = chromeURL;
|
||||
win.arguments = args; // <-- needs to be a plain JS array here.
|
||||
|
||||
ChromeUtils.addProfilerMarker("earlyBlankWindowVisible", openTime);
|
||||
lazy.BrowserWindowTracker.registerOpeningWindow(win, forcePrivate);
|
||||
return win;
|
||||
}
|
||||
}
|
||||
|
@ -350,11 +350,13 @@ function openBrowserWindow(
|
|||
args = array;
|
||||
}
|
||||
|
||||
return lazy.BrowserWindowTracker.openWindow({
|
||||
args,
|
||||
features: gBrowserContentHandler.getFeatures(cmdLine),
|
||||
private: forcePrivate,
|
||||
});
|
||||
let features =
|
||||
"chrome,dialog=no,all" + gBrowserContentHandler.getFeatures(cmdLine);
|
||||
if (forcePrivate) {
|
||||
features += ",private";
|
||||
}
|
||||
|
||||
return Services.ww.openWindow(null, chromeURL, "_blank", features, args);
|
||||
}
|
||||
|
||||
function openPreferences(cmdLine, extraArgs) {
|
||||
|
@ -929,7 +931,7 @@ nsBrowserContentHandler.prototype = {
|
|||
};
|
||||
var gBrowserContentHandler = new nsBrowserContentHandler();
|
||||
|
||||
async function handURIToExistingBrowser(
|
||||
function handURIToExistingBrowser(
|
||||
uri,
|
||||
location,
|
||||
cmdLine,
|
||||
|
@ -947,13 +949,6 @@ async function handURIToExistingBrowser(
|
|||
var navWin = lazy.BrowserWindowTracker.getTopWindow({
|
||||
private: allowPrivate,
|
||||
});
|
||||
|
||||
if (!navWin) {
|
||||
navWin = await lazy.BrowserWindowTracker.getPendingWindow({
|
||||
private: allowPrivate,
|
||||
});
|
||||
}
|
||||
|
||||
if (!navWin) {
|
||||
// if we couldn't load it in an existing window, open a new one
|
||||
openBrowserWindow(
|
||||
|
|
|
@ -9,16 +9,11 @@
|
|||
|
||||
var EXPORTED_SYMBOLS = ["BrowserWindowTracker"];
|
||||
|
||||
const { AppConstants } = ChromeUtils.importESModule(
|
||||
"resource://gre/modules/AppConstants.sys.mjs"
|
||||
);
|
||||
|
||||
const lazy = {};
|
||||
|
||||
// Lazy getters
|
||||
ChromeUtils.defineESModuleGetters(lazy, {
|
||||
PrivateBrowsingUtils: "resource://gre/modules/PrivateBrowsingUtils.sys.mjs",
|
||||
PromiseUtils: "resource://gre/modules/PromiseUtils.sys.mjs",
|
||||
});
|
||||
|
||||
// Constants
|
||||
|
@ -150,8 +145,6 @@ var WindowHelper = {
|
|||
};
|
||||
|
||||
const BrowserWindowTracker = {
|
||||
pendingWindows: new Map(),
|
||||
|
||||
/**
|
||||
* Get the most recent browser window.
|
||||
*
|
||||
|
@ -176,90 +169,6 @@ const BrowserWindowTracker = {
|
|||
return null;
|
||||
},
|
||||
|
||||
/**
|
||||
* Get a window that is in the process of loading. Only supports windows
|
||||
* opened via the `openWindow` function in this module or that have been
|
||||
* registered with the `registerOpeningWindow` function.
|
||||
*
|
||||
* @param {Object} options
|
||||
* Options for the search.
|
||||
* @param {boolean} [options.private]
|
||||
* true to restrict the search to private windows only, false to restrict
|
||||
* the search to non-private only. Omit the property to search in both
|
||||
* groups.
|
||||
*
|
||||
* @returns {Promise<Window> | null}
|
||||
*/
|
||||
getPendingWindow(options = {}) {
|
||||
for (let pending of this.pendingWindows.values()) {
|
||||
if (
|
||||
!("private" in options) ||
|
||||
lazy.PrivateBrowsingUtils.permanentPrivateBrowsing ||
|
||||
pending.isPrivate == options.private
|
||||
) {
|
||||
return pending.deferred.promise;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
},
|
||||
|
||||
/**
|
||||
* Registers a browser window that is in the process of opening. Normally it
|
||||
* would be preferable to use the standard method for opening the window from
|
||||
* this module.
|
||||
*
|
||||
* @param {Window} window
|
||||
* The opening window.
|
||||
* @param {boolean} isPrivate
|
||||
* Whether the opening window is a private browsing window.
|
||||
*/
|
||||
registerOpeningWindow(window, isPrivate) {
|
||||
let deferred = lazy.PromiseUtils.defer();
|
||||
|
||||
this.pendingWindows.set(window, {
|
||||
isPrivate,
|
||||
deferred,
|
||||
});
|
||||
},
|
||||
|
||||
/**
|
||||
* A standard function for opening a new browser window.
|
||||
*
|
||||
* @param {Object} [options]
|
||||
* Options for the new window.
|
||||
* @param {boolean} [options.private]
|
||||
* True to make the window a private browsing window.
|
||||
* @param {String} [options.features]
|
||||
* Additional window features to give the new window.
|
||||
* @param {nsIArray | nsISupportsString} [options.args]
|
||||
* Arguments to pass to the new window.
|
||||
*
|
||||
* @returns {Window}
|
||||
*/
|
||||
openWindow({
|
||||
private: isPrivate = false,
|
||||
features = undefined,
|
||||
args = null,
|
||||
} = {}) {
|
||||
let windowFeatures = "chrome,dialog=no,all";
|
||||
if (features) {
|
||||
windowFeatures += `,${features}`;
|
||||
}
|
||||
if (isPrivate) {
|
||||
windowFeatures += ",private";
|
||||
}
|
||||
|
||||
let win = Services.ww.openWindow(
|
||||
null,
|
||||
AppConstants.BROWSER_CHROME_URL,
|
||||
"_blank",
|
||||
windowFeatures,
|
||||
args
|
||||
);
|
||||
this.registerOpeningWindow(win, isPrivate);
|
||||
return win;
|
||||
},
|
||||
|
||||
windowCreated(browser) {
|
||||
if (browser === browser.ownerGlobal.gBrowser.selectedBrowser) {
|
||||
_updateCurrentBrowsingContextID(browser);
|
||||
|
@ -298,14 +207,6 @@ const BrowserWindowTracker = {
|
|||
},
|
||||
|
||||
track(window) {
|
||||
let pending = this.pendingWindows.get(window);
|
||||
if (pending) {
|
||||
this.pendingWindows.delete(window);
|
||||
// Waiting for delayed startup to complete ensures that this new window
|
||||
// has started loading its initial urls.
|
||||
window.delayedStartupPromise.then(() => pending.deferred.resolve(window));
|
||||
}
|
||||
|
||||
return WindowHelper.addWindow(window);
|
||||
},
|
||||
|
||||
|
|
|
@ -164,78 +164,3 @@ add_task(async function test_orderedWindows() {
|
|||
);
|
||||
});
|
||||
});
|
||||
|
||||
add_task(async function test_pendingWindows() {
|
||||
Assert.equal(
|
||||
BrowserWindowTracker.windowCount,
|
||||
1,
|
||||
"Number of tracked windows, including the test window"
|
||||
);
|
||||
|
||||
let pending = BrowserWindowTracker.getPendingWindow();
|
||||
Assert.equal(pending, null, "Should be no pending window");
|
||||
|
||||
let expectedWin = BrowserWindowTracker.openWindow();
|
||||
pending = BrowserWindowTracker.getPendingWindow();
|
||||
Assert.ok(pending, "Should be a pending window now.");
|
||||
Assert.ok(
|
||||
!BrowserWindowTracker.getPendingWindow({ private: true }),
|
||||
"Should not be a pending private window"
|
||||
);
|
||||
Assert.equal(
|
||||
pending,
|
||||
BrowserWindowTracker.getPendingWindow({ private: false }),
|
||||
"Should be the same non-private window pending"
|
||||
);
|
||||
|
||||
let foundWin = await pending;
|
||||
Assert.equal(foundWin, expectedWin, "Should have found the right window");
|
||||
Assert.ok(
|
||||
!BrowserWindowTracker.getPendingWindow(),
|
||||
"Should be no pending window now."
|
||||
);
|
||||
|
||||
await BrowserTestUtils.closeWindow(foundWin);
|
||||
|
||||
expectedWin = BrowserWindowTracker.openWindow({ private: true });
|
||||
pending = BrowserWindowTracker.getPendingWindow();
|
||||
Assert.ok(pending, "Should be a pending window now.");
|
||||
Assert.ok(
|
||||
!BrowserWindowTracker.getPendingWindow({ private: false }),
|
||||
"Should not be a pending non-private window"
|
||||
);
|
||||
Assert.equal(
|
||||
pending,
|
||||
BrowserWindowTracker.getPendingWindow({ private: true }),
|
||||
"Should be the same private window pending"
|
||||
);
|
||||
|
||||
foundWin = await pending;
|
||||
Assert.equal(foundWin, expectedWin, "Should have found the right window");
|
||||
Assert.ok(
|
||||
!BrowserWindowTracker.getPendingWindow(),
|
||||
"Should be no pending window now."
|
||||
);
|
||||
|
||||
await BrowserTestUtils.closeWindow(foundWin);
|
||||
|
||||
expectedWin = Services.ww.openWindow(
|
||||
null,
|
||||
AppConstants.BROWSER_CHROME_URL,
|
||||
"_blank",
|
||||
"chrome,dialog=no,all",
|
||||
null
|
||||
);
|
||||
BrowserWindowTracker.registerOpeningWindow(expectedWin, false);
|
||||
pending = BrowserWindowTracker.getPendingWindow();
|
||||
Assert.ok(pending, "Should be a pending window now.");
|
||||
|
||||
foundWin = await pending;
|
||||
Assert.equal(foundWin, expectedWin, "Should have found the right window");
|
||||
Assert.ok(
|
||||
!BrowserWindowTracker.getPendingWindow(),
|
||||
"Should be no pending window now."
|
||||
);
|
||||
|
||||
await BrowserTestUtils.closeWindow(foundWin);
|
||||
});
|
||||
|
|
|
@ -52,34 +52,27 @@ void nsRemoteService::LockStartup() {
|
|||
nsCOMPtr<nsIFile> mutexDir;
|
||||
nsresult rv = GetSpecialSystemDirectory(OS_TemporaryDirectory,
|
||||
getter_AddRefs(mutexDir));
|
||||
NS_ENSURE_SUCCESS_VOID(rv);
|
||||
rv = mutexDir->AppendNative(mProgram);
|
||||
NS_ENSURE_SUCCESS_VOID(rv);
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
mutexDir->AppendNative(mProgram);
|
||||
|
||||
const mozilla::TimeStamp epoch = mozilla::TimeStamp::Now();
|
||||
do {
|
||||
// If we have been waiting for another instance to release the lock it will
|
||||
// have deleted the lock directory when doing so we have to make sure it
|
||||
// exists every time we poll for the lock.
|
||||
rv = mutexDir->Create(nsIFile::DIRECTORY_TYPE, 0700);
|
||||
if (NS_SUCCEEDED(rv) || rv == NS_ERROR_FILE_ALREADY_EXISTS) {
|
||||
mRemoteLockDir = mutexDir;
|
||||
} else {
|
||||
NS_WARNING("Unable to create startup lock directory.");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
rv = mRemoteLock.Lock(mRemoteLockDir, nullptr);
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
return;
|
||||
if (mRemoteLockDir) {
|
||||
const mozilla::TimeStamp epoch = mozilla::TimeStamp::Now();
|
||||
do {
|
||||
rv = mRemoteLock.Lock(mRemoteLockDir, nullptr);
|
||||
if (NS_SUCCEEDED(rv)) break;
|
||||
PR_Sleep(START_SLEEP_MSEC);
|
||||
} while ((mozilla::TimeStamp::Now() - epoch) <
|
||||
mozilla::TimeDuration::FromSeconds(START_TIMEOUT_SEC));
|
||||
if (NS_FAILED(rv)) {
|
||||
NS_WARNING("Cannot lock remote start mutex");
|
||||
}
|
||||
|
||||
mRemoteLockDir = nullptr;
|
||||
PR_Sleep(START_SLEEP_MSEC);
|
||||
} while ((mozilla::TimeStamp::Now() - epoch) <
|
||||
mozilla::TimeDuration::FromSeconds(START_TIMEOUT_SEC));
|
||||
|
||||
NS_WARNING("Failed to lock for startup, continuing anyway.");
|
||||
}
|
||||
}
|
||||
|
||||
void nsRemoteService::UnlockStartup() {
|
||||
|
|
Загрузка…
Ссылка в новой задаче