Source code

Revision control

Other Tools

1
/* This Source Code Form is subject to the terms of the Mozilla Public
2
* License, v. 2.0. If a copy of the MPL was not distributed with this
3
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
4
"use strict";
5
6
var EXPORTED_SYMBOLS = ["BrowserTabParent"];
7
8
class BrowserTabParent extends JSWindowActorParent {
9
receiveMessage(message) {
10
let browser = this.manager.browsingContext.embedderElement;
11
if (!browser) {
12
return; // Can happen sometimes if browser is being destroyed
13
}
14
15
if (browser.outerBrowser) {
16
browser = browser.outerBrowser; // handle RDM mode
17
}
18
19
let gBrowser = browser.ownerGlobal.gBrowser;
20
21
if (!gBrowser) {
22
// Note: gBrowser might be null because this message might be received
23
// from the extension process. There's still an embedderElement involved,
24
// but it's the one coming from dummy.xul.
25
// This should probably be fixed by adding support to specifying "group: 'browsers"
26
// in the registerWindowActor options/. See bug 1557118.
27
return;
28
}
29
30
if (!gBrowser.tabpanels || !gBrowser.tabpanels.contains(browser)) {
31
// Note: This is ignoring browser elements related to extension pages that are not loaded
32
// as a browser tab (like sidebars, devtools panels and options pages embedded into
33
// about:addons, browserAction and pageAction popup panels.
34
// (Ideally we could call gBrowser.getTabForBrowser, but it returns undefined early in
35
// the tab browser creation and we would ignore browsers related to newly created tabs).
36
return;
37
}
38
39
switch (message.name) {
40
case "Browser:WindowCreated": {
41
gBrowser.announceWindowCreated(browser, message.data.userContextId);
42
break;
43
}
44
45
case "Browser:FirstPaint": {
46
browser.ownerGlobal.gBrowserInit._firstBrowserPaintDeferred.resolve();
47
break;
48
}
49
50
case "Browser:LoadURI": {
51
gBrowser.ownerGlobal.RedirectLoad(browser, message.data);
52
break;
53
}
54
55
case "PointerLock:Entered": {
56
browser.ownerGlobal.PointerLock.entered(message.data.originNoSuffix);
57
break;
58
}
59
60
case "PointerLock:Exited":
61
browser.ownerGlobal.PointerLock.exited();
62
break;
63
}
64
}
65
}