Bug 1019990 - about:newtab preloader should load content.js. r=ttaubert

This commit is contained in:
Drew Willcoxon 2014-06-17 12:35:34 -07:00
Родитель 758bc9d5d2
Коммит d962fbd62a
5 изменённых файлов: 23 добавлений и 7 удалений

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

@ -238,8 +238,5 @@ let gPage = {
let shownCount = Math.min(10, count);
Services.telemetry.getHistogramById(shownId).add(shownCount);
}
// Set up initial search state.
gSearch.setUpInitialState();
}
};

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

@ -15,9 +15,6 @@ let gSearch = {
}
window.addEventListener("ContentSearchService", this);
},
setUpInitialState: function () {
this._send("GetState");
},

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

@ -2273,6 +2273,8 @@
// Give others a chance to swap state.
let event = new CustomEvent("SwapDocShells", {"detail": aOtherBrowser});
ourBrowser.dispatchEvent(event);
event = new CustomEvent("SwapDocShells", {"detail": ourBrowser});
aOtherBrowser.dispatchEvent(event);
// Swap the docshells
ourBrowser.swapDocShells(aOtherBrowser);

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

@ -35,6 +35,8 @@ const TOPIC_TIMER_CALLBACK = "timer-callback";
const TOPIC_DELAYED_STARTUP = "browser-delayed-startup-finished";
const TOPIC_XUL_WINDOW_CLOSED = "xul-window-destroyed";
const BROWSER_CONTENT_SCRIPT = "chrome://browser/content/content.js";
function createTimer(obj, delay) {
let timer = Cc["@mozilla.org/timer;1"].createInstance(Ci.nsITimer);
timer.init(obj, delay, Ci.nsITimer.TYPE_ONE_SHOT);
@ -321,9 +323,14 @@ HiddenBrowser.prototype = {
tabbrowser.swapNewTabWithBrowser(aTab, this._browser);
// Load all delayed frame scripts attached to the "browers" message manager.
// The browser content script was already loaded, so don't load it again.
let mm = aTab.linkedBrowser.messageManager;
let scripts = win.getGroupMessageManager("browsers").getDelayedFrameScripts();
Array.forEach(scripts, ([script, runGlobal]) => mm.loadFrameScript(script, true, runGlobal));
Array.forEach(scripts, ([script, runGlobal]) => {
if (script != BROWSER_CONTENT_SCRIPT) {
mm.loadFrameScript(script, true, runGlobal);
}
});
// Remove the browser, it will be recreated by a timer.
this._removeBrowser();
@ -371,6 +378,9 @@ HiddenBrowser.prototype = {
// Let the docShell be inactive so that document.hidden=true.
this._browser.docShell.isActive = false;
this._browser.messageManager.loadFrameScript(BROWSER_CONTENT_SCRIPT,
true);
});
},

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

@ -68,6 +68,15 @@ this.ContentSearch = {
},
receiveMessage: function (msg) {
// Add a temporary event handler that exists only while the message is in
// the event queue. If the message's source docshell changes browsers in
// the meantime, then we need to update msg.target. event.detail will be
// the docshell's new parent <xul:browser> element.
msg.handleEvent = function (event) {
this.target = event.detail;
};
msg.target.addEventListener("SwapDocShells", msg, true);
this._eventQueue.push({
type: "Message",
data: msg,
@ -106,6 +115,7 @@ this.ContentSearch = {
if (methodName in this) {
yield this._initService();
yield this[methodName](msg, msg.data.data);
msg.target.removeEventListener("SwapDocShells", msg, true);
}
}),