@@ -1838,7 +1838,7 @@ index 0000000000000000000000000000000000000000..ba34976ad05e7f5f1a99777f76ac08b1
1838
1838
+ this.SimpleChannel = SimpleChannel;
1839
1839
diff --git a/juggler/TargetRegistry.js b/juggler/TargetRegistry.js
1840
1840
new file mode 100644
1841
- index 0000000000000000000000000000000000000000..eab73deee89cc7c8ab0a304f79126264de5c4f8e
1841
+ index 0000000000000000000000000000000000000000..e438996fbc04d2eec36436b7e3007649ed088286
1842
1842
--- /dev/null
1843
1843
+++ b/juggler/TargetRegistry.js
1844
1844
@@ -0,0 +1,264 @@
@@ -1881,8 +1881,8 @@ index 0000000000000000000000000000000000000000..eab73deee89cc7c8ab0a304f79126264
1881
1881
+ this._mainWindow.gBrowser.tabContainer.addEventListener('TabOpen', event => {
1882
1882
+ const target = this._createTargetForTab(event.target);
1883
1883
+ // If we come here, content will have juggler script from the start,
1884
- + // and we should wait for initial navigation, unless the tab was window.open'ed .
1885
- + target._waitForInitialNavigation = !event.target.linkedBrowser.hasContentOpener ;
1884
+ + // and we should wait for initial navigation.
1885
+ + target._waitForInitialNavigation = true ;
1886
1886
+ // For pages created before we attach to them, we don't wait for initial
1887
1887
+ // navigation (target._waitForInitialNavigation is false by default).
1888
1888
+ });
@@ -2254,10 +2254,10 @@ index 0000000000000000000000000000000000000000..268fbc361d8053182bb6c27f626e853d
2254
2254
+
2255
2255
diff --git a/juggler/content/FrameTree.js b/juggler/content/FrameTree.js
2256
2256
new file mode 100644
2257
- index 0000000000000000000000000000000000000000..1197aec925e07a52c5802e09e9fd797b48091fd3
2257
+ index 0000000000000000000000000000000000000000..13c3cd817b369ed012326b97d03ba6e123b84740
2258
2258
--- /dev/null
2259
2259
+++ b/juggler/content/FrameTree.js
2260
- @@ -0,0 +1,370 @@
2260
+ @@ -0,0 +1,376 @@
2261
2261
+ "use strict";
2262
2262
+ const Ci = Components.interfaces;
2263
2263
+ const Cr = Components.results;
@@ -2355,6 +2355,14 @@ index 0000000000000000000000000000000000000000..1197aec925e07a52c5802e09e9fd797b
2355
2355
+ return this._pageReady;
2356
2356
+ }
2357
2357
+
2358
+ + forcePageReady() {
2359
+ + if (this._pageReady)
2360
+ + return false;
2361
+ + this._pageReady = true;
2362
+ + this.emit(FrameTree.Events.PageReady);
2363
+ + return true;
2364
+ + }
2365
+ +
2358
2366
+ addScriptToEvaluateOnNewDocument(script) {
2359
2367
+ this._scriptsToEvaluateOnNewDocument.push(script);
2360
2368
+ }
@@ -2423,10 +2431,8 @@ index 0000000000000000000000000000000000000000..1197aec925e07a52c5802e09e9fd797b
2423
2431
+ frame._lastCommittedNavigationId = navigationId;
2424
2432
+ frame._url = channel.URI.spec;
2425
2433
+ this.emit(FrameTree.Events.NavigationCommitted, frame);
2426
- + if (frame === this._mainFrame && !this._pageReady) {
2427
- + this._pageReady = true;
2428
- + this.emit(FrameTree.Events.PageReady);
2429
- + }
2434
+ + if (frame === this._mainFrame)
2435
+ + this.forcePageReady();
2430
2436
+ } else if (isStop && frame._pendingNavigationId && status) {
2431
2437
+ // Navigation is aborted.
2432
2438
+ const navigationId = frame._pendingNavigationId;
@@ -2698,10 +2704,10 @@ index 0000000000000000000000000000000000000000..be70ea364f9534bb3b344f64970366c3
2698
2704
+
2699
2705
diff --git a/juggler/content/PageAgent.js b/juggler/content/PageAgent.js
2700
2706
new file mode 100644
2701
- index 0000000000000000000000000000000000000000..fb207d8b39bee7c1365428a171f80c438097d2bb
2707
+ index 0000000000000000000000000000000000000000..ccf881cfee36a1f47fbab880202cc72e7e98e387
2702
2708
--- /dev/null
2703
2709
+++ b/juggler/content/PageAgent.js
2704
- @@ -0,0 +1,945 @@
2710
+ @@ -0,0 +1,964 @@
2705
2711
+ "use strict";
2706
2712
+ const {Services} = ChromeUtils.import("resource://gre/modules/Services.jsm");
2707
2713
+ const Ci = Components.interfaces;
@@ -2990,6 +2996,7 @@ index 0000000000000000000000000000000000000000..fb207d8b39bee7c1365428a171f80c43
2990
2996
+ helper.on(this._frameTree, 'pageready', () => this._browserPage.emit('pageReady', {})),
2991
2997
+ helper.on(this._frameTree, 'workercreated', this._onWorkerCreated.bind(this)),
2992
2998
+ helper.on(this._frameTree, 'workerdestroyed', this._onWorkerDestroyed.bind(this)),
2999
+ + helper.addObserver(this._onWindowOpen.bind(this), 'webNavigation-createdNavigationTarget-from-js'),
2993
3000
+ ]);
2994
3001
+
2995
3002
+ if (this._frameTree.isPageReady())
@@ -3017,6 +3024,24 @@ index 0000000000000000000000000000000000000000..fb207d8b39bee7c1365428a171f80c43
3017
3024
+ });
3018
3025
+ }
3019
3026
+
3027
+ + _onWindowOpen(subject) {
3028
+ + if (!(subject instanceof Ci.nsIPropertyBag2))
3029
+ + return;
3030
+ + const props = subject.QueryInterface(Ci.nsIPropertyBag2);
3031
+ + const hasUrl = props.hasKey('url');
3032
+ + const createdDocShell = props.getPropertyAsInterface('createdTabDocShell', Ci.nsIDocShell);
3033
+ + if (!hasUrl && createdDocShell === this._docShell && this._frameTree.forcePageReady()) {
3034
+ + this._browserPage.emit('pageEventFired', {
3035
+ + frameId: this._frameTree.mainFrame().id(),
3036
+ + name: 'DOMContentLoaded',
3037
+ + });
3038
+ + this._browserPage.emit('pageEventFired', {
3039
+ + frameId: this._frameTree.mainFrame().id(),
3040
+ + name: 'load',
3041
+ + });
3042
+ + }
3043
+ + }
3044
+ +
3020
3045
+ _setInterceptFileChooserDialog({enabled}) {
3021
3046
+ this._docShell.fileInputInterceptionEnabled = !!enabled;
3022
3047
+ }
0 commit comments