mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 896711: remove BrowserChromeTests.runWhenReady because it's being abused, r=dao/ttaubert/vporof
This commit is contained in:
parent
f2263799bc
commit
24f5a48b6e
@ -1206,8 +1206,6 @@ var gBrowserInit = {
|
||||
|
||||
SocialUI.init();
|
||||
TabView.init();
|
||||
|
||||
setTimeout(function () { BrowserChromeTest.markAsReady(); }, 0);
|
||||
});
|
||||
this.delayedStartupFinished = true;
|
||||
|
||||
@ -7184,23 +7182,6 @@ function focusNextFrame(event) {
|
||||
if (element.ownerDocument == document)
|
||||
focusAndSelectUrlBar();
|
||||
}
|
||||
let BrowserChromeTest = {
|
||||
_cb: null,
|
||||
_ready: false,
|
||||
markAsReady: function () {
|
||||
this._ready = true;
|
||||
if (this._cb) {
|
||||
this._cb();
|
||||
this._cb = null;
|
||||
}
|
||||
},
|
||||
runWhenReady: function (cb) {
|
||||
if (this._ready)
|
||||
cb();
|
||||
else
|
||||
this._cb = cb;
|
||||
}
|
||||
};
|
||||
|
||||
function BrowserOpenNewTabOrWindow(event) {
|
||||
if (event.shiftKey) {
|
||||
|
@ -1,13 +1,14 @@
|
||||
/* Any copyright is dedicated to the Public Domain.
|
||||
* http://creativecommons.org/publicdomain/zero/1.0/ */
|
||||
|
||||
function whenNewWindowLoaded(aOptions, aCallback) {
|
||||
let win = OpenBrowserWindow(aOptions);
|
||||
let gotLoad = false;
|
||||
let gotActivate = (Cc["@mozilla.org/focus-manager;1"].getService(Ci.nsIFocusManager).activeWindow == win);
|
||||
let gotActivate = Services.focus.activeWindow == win;
|
||||
|
||||
function maybeRunCallback() {
|
||||
if (gotLoad && gotActivate) {
|
||||
win.BrowserChromeTest.runWhenReady(function() {
|
||||
executeSoon(function() { aCallback(win); });
|
||||
});
|
||||
executeSoon(function() { aCallback(win); });
|
||||
}
|
||||
}
|
||||
|
||||
@ -22,12 +23,15 @@ function whenNewWindowLoaded(aOptions, aCallback) {
|
||||
info("Was activated.");
|
||||
}
|
||||
|
||||
win.addEventListener("load", function onLoad() {
|
||||
info("Got load");
|
||||
win.removeEventListener("load", onLoad, false);
|
||||
gotLoad = true;
|
||||
maybeRunCallback();
|
||||
}, false);
|
||||
Services.obs.addObserver(function observer(aSubject, aTopic) {
|
||||
if (win == aSubject) {
|
||||
info("Delayed startup finished");
|
||||
Services.obs.removeObserver(observer, aTopic);
|
||||
gotLoad = true;
|
||||
maybeRunCallback();
|
||||
}
|
||||
}, "browser-delayed-startup-finished", false);
|
||||
|
||||
return win;
|
||||
}
|
||||
|
||||
|
@ -4,13 +4,11 @@
|
||||
function whenNewWindowLoaded(aOptions, aCallback) {
|
||||
let win = OpenBrowserWindow(aOptions);
|
||||
let gotLoad = false;
|
||||
let gotActivate = (Cc["@mozilla.org/focus-manager;1"].getService(Ci.nsIFocusManager).activeWindow == win);
|
||||
let gotActivate = Services.focus.activeWindow == win;
|
||||
|
||||
function maybeRunCallback() {
|
||||
if (gotLoad && gotActivate) {
|
||||
win.BrowserChromeTest.runWhenReady(function() {
|
||||
executeSoon(function() { aCallback(win); });
|
||||
});
|
||||
executeSoon(function() { aCallback(win); });
|
||||
}
|
||||
}
|
||||
|
||||
@ -25,12 +23,15 @@ function whenNewWindowLoaded(aOptions, aCallback) {
|
||||
info("Was activated.");
|
||||
}
|
||||
|
||||
win.addEventListener("load", function onLoad() {
|
||||
info("Got load");
|
||||
win.removeEventListener("load", onLoad, false);
|
||||
gotLoad = true;
|
||||
maybeRunCallback();
|
||||
}, false);
|
||||
Services.obs.addObserver(function observer(aSubject, aTopic) {
|
||||
if (win == aSubject) {
|
||||
info("Delayed startup finished");
|
||||
Services.obs.removeObserver(observer, aTopic);
|
||||
gotLoad = true;
|
||||
maybeRunCallback();
|
||||
}
|
||||
}, "browser-delayed-startup-finished", false);
|
||||
|
||||
return win;
|
||||
}
|
||||
|
||||
|
@ -39,21 +39,18 @@ function testCleanExit() {
|
||||
let isLoaded = promise.defer();
|
||||
|
||||
promise.all([isActive.promise, isLoaded.promise]).then(() => {
|
||||
gWindow.BrowserChromeTest.runWhenReady(() => {
|
||||
waitForSourceAndCaretAndScopes(gPanel, ".html", 16).then(() => {
|
||||
is(gDebugger.gThreadClient.paused, true,
|
||||
"Should be paused after the debugger statement.");
|
||||
gWindow.close();
|
||||
deferred.resolve();
|
||||
finish();
|
||||
});
|
||||
|
||||
gDebuggee.runDebuggerStatement();
|
||||
waitForSourceAndCaretAndScopes(gPanel, ".html", 16).then(() => {
|
||||
is(gDebugger.gThreadClient.paused, true,
|
||||
"Should be paused after the debugger statement.");
|
||||
gWindow.close();
|
||||
deferred.resolve();
|
||||
finish();
|
||||
});
|
||||
|
||||
gDebuggee.runDebuggerStatement();
|
||||
});
|
||||
|
||||
let focusManager = Cc["@mozilla.org/focus-manager;1"].getService(Ci.nsIFocusManager);
|
||||
if (focusManager.activeWindow != gWindow) {
|
||||
if (Services.focus.activeWindow != gWindow) {
|
||||
gWindow.addEventListener("activate", function onActivate(aEvent) {
|
||||
if (aEvent.target != gWindow) {
|
||||
return;
|
||||
|
@ -75,18 +75,15 @@ function testNewWindow(aWindow) {
|
||||
let isLoaded = promise.defer();
|
||||
|
||||
promise.all([isActive.promise, isLoaded.promise]).then(() => {
|
||||
gNewWindow.BrowserChromeTest.runWhenReady(() => {
|
||||
gClient.listTabs(aResponse => {
|
||||
is(aResponse.selected, 2,
|
||||
"The second tab is selected.");
|
||||
gClient.listTabs(aResponse => {
|
||||
is(aResponse.selected, 2,
|
||||
"The second tab is selected.");
|
||||
|
||||
deferred.resolve();
|
||||
});
|
||||
deferred.resolve();
|
||||
});
|
||||
});
|
||||
|
||||
let focusManager = Cc["@mozilla.org/focus-manager;1"].getService(Ci.nsIFocusManager);
|
||||
if (focusManager.activeWindow != gNewWindow) {
|
||||
if (Services.focus.activeWindow != gNewWindow) {
|
||||
gNewWindow.addEventListener("activate", function onActivate(aEvent) {
|
||||
if (aEvent.target != gNewWindow) {
|
||||
return;
|
||||
@ -118,10 +115,6 @@ function testFocusFirst() {
|
||||
let deferred = promise.defer();
|
||||
|
||||
once(window.content, "focus").then(() => {
|
||||
let topWindow = Services.wm.getMostRecentWindow("navigator:browser");
|
||||
is(top, getDOMWindow(window),
|
||||
"The first window is on top.");
|
||||
|
||||
gClient.listTabs(aResponse => {
|
||||
is(aResponse.selected, 1,
|
||||
"The first tab is selected after focusing on it.");
|
||||
|
@ -62,11 +62,11 @@ function dbg_assert(cond, e) {
|
||||
|
||||
function addWindow(aUrl) {
|
||||
info("Adding window: " + aUrl);
|
||||
return promise.resolve(getDOMWindow(window.open(aUrl)));
|
||||
return promise.resolve(getChromeWindow(window.open(aUrl)));
|
||||
}
|
||||
|
||||
function getDOMWindow(aReference) {
|
||||
return aReference
|
||||
function getChromeWindow(aWindow) {
|
||||
return aWindow
|
||||
.QueryInterface(Ci.nsIInterfaceRequestor).getInterface(Ci.nsIWebNavigation)
|
||||
.QueryInterface(Ci.nsIDocShellTreeItem).rootTreeItem
|
||||
.QueryInterface(Ci.nsIInterfaceRequestor).getInterface(Ci.nsIDOMWindow);
|
||||
|
@ -1,3 +1,6 @@
|
||||
/* Any copyright is dedicated to the Public Domain.
|
||||
http://creativecommons.org/publicdomain/zero/1.0/ */
|
||||
|
||||
function test() {
|
||||
var prefs = Components.classes["@mozilla.org/preferences-service;1"].getService(Components.interfaces.nsIPrefBranch);
|
||||
let baseProvider = "http://mochi.test:8888/browser/dom/tests/browser/network_geolocation.sjs";
|
||||
@ -19,30 +22,35 @@ function test() {
|
||||
function testOnWindow(aIsPrivate, aCallback) {
|
||||
let win = OpenBrowserWindow({private: aIsPrivate});
|
||||
let gotLoad = false;
|
||||
let gotActivate =
|
||||
(Cc["@mozilla.org/focus-manager;1"].getService(Ci.nsIFocusManager).activeWindow == win);
|
||||
let gotActivate = Services.focus.activeWindow == win;
|
||||
|
||||
function maybeRunCallback() {
|
||||
if (gotLoad && gotActivate) {
|
||||
windowsToClose.push(win);
|
||||
executeSoon(function() { aCallback(win); });
|
||||
}
|
||||
}
|
||||
|
||||
if (!gotActivate) {
|
||||
win.addEventListener("activate", function onActivate() {
|
||||
info("got activate");
|
||||
win.removeEventListener("activate", onActivate, true);
|
||||
gotActivate = true;
|
||||
if (gotLoad) {
|
||||
windowsToClose.push(win);
|
||||
win.BrowserChromeTest.runWhenReady(function() { aCallback(win) });
|
||||
}
|
||||
maybeRunCallback();
|
||||
}, true);
|
||||
} else {
|
||||
info("Was activated");
|
||||
}
|
||||
win.addEventListener("load", function onLoad() {
|
||||
info("Got load");
|
||||
win.removeEventListener("load", onLoad, true);
|
||||
gotLoad = true;
|
||||
if (gotActivate) {
|
||||
windowsToClose.push(win);
|
||||
setTimeout(function() { aCallback(win) }, 1000);
|
||||
|
||||
Services.obs.addObserver(function observer(aSubject, aTopic) {
|
||||
if (win == aSubject) {
|
||||
info("Delayed startup finished");
|
||||
Services.obs.removeObserver(observer, aTopic);
|
||||
gotLoad = true;
|
||||
maybeRunCallback();
|
||||
}
|
||||
}, true);
|
||||
}, "browser-delayed-startup-finished", false);
|
||||
|
||||
}
|
||||
|
||||
testOnWindow(false, function(aNormalWindow) {
|
||||
|
@ -24,11 +24,15 @@ XPCOMUtils.defineLazyModuleGetter(this, "CustomizationTabPreloader",
|
||||
const SIMPLETEST_OVERRIDES =
|
||||
["ok", "is", "isnot", "ise", "todo", "todo_is", "todo_isnot", "info", "expectAssertions"];
|
||||
|
||||
window.addEventListener("load", testOnLoad, false);
|
||||
|
||||
function testOnLoad() {
|
||||
window.removeEventListener("load", testOnLoad, false);
|
||||
window.addEventListener("load", function testOnLoad() {
|
||||
window.removeEventListener("load", testOnLoad);
|
||||
window.addEventListener("MozAfterPaint", function testOnMozAfterPaint() {
|
||||
window.removeEventListener("MozAfterPaint", testOnMozAfterPaint);
|
||||
setTimeout(testInit, 0);
|
||||
});
|
||||
});
|
||||
|
||||
function testInit() {
|
||||
gConfig = readConfig();
|
||||
if (gConfig.testRoot == "browser" ||
|
||||
gConfig.testRoot == "metro" ||
|
||||
@ -143,15 +147,6 @@ Tester.prototype = {
|
||||
},
|
||||
|
||||
start: function Tester_start() {
|
||||
// Check whether this window is ready to run tests.
|
||||
if (window.BrowserChromeTest) {
|
||||
BrowserChromeTest.runWhenReady(this.actuallyStart.bind(this));
|
||||
return;
|
||||
}
|
||||
this.actuallyStart();
|
||||
},
|
||||
|
||||
actuallyStart: function Tester_actuallyStart() {
|
||||
//if testOnLoad was not called, then gConfig is not defined
|
||||
if (!gConfig)
|
||||
gConfig = readConfig();
|
||||
|
Loading…
Reference in New Issue
Block a user