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
let gBrowser = browser.ownerGlobal.gBrowser;
16
17
if (!gBrowser) {
18
// Note: gBrowser might be null because this message might be received
19
// from the extension process. There's still an embedderElement involved,
20
// but it's the one coming from dummy.xul.
21
// This should probably be fixed by adding support to specifying "group: 'browsers"
22
// in the registerWindowActor options/. See bug 1557118.
23
return;
24
}
25
26
if (!gBrowser.tabpanels || !gBrowser.tabpanels.contains(browser)) {
27
// Note: This is ignoring browser elements related to extension pages that are not loaded
28
// as a browser tab (like sidebars, devtools panels and options pages embedded into
29
// about:addons, browserAction and pageAction popup panels.
30
// (Ideally we could call gBrowser.getTabForBrowser, but it returns undefined early in
31
// the tab browser creation and we would ignore browsers related to newly created tabs).
32
return;
33
}
34
35
switch (message.name) {
36
case "Browser:WindowCreated": {
37
gBrowser.announceWindowCreated(browser, message.data.userContextId);
38
break;
39
}
40
41
case "Browser:FirstPaint": {
42
browser.ownerGlobal.gBrowserInit._firstBrowserPaintDeferred.resolve();
43
break;
44
}
45
46
case "PointerLock:Entered": {
47
browser.ownerGlobal.PointerLock.entered(message.data.originNoSuffix);
48
break;
49
}
50
51
case "PointerLock:Exited":
52
browser.ownerGlobal.PointerLock.exited();
53
break;
54
}
55
}
56
}