browser/components/preferences/in-content/tests/browser_subdialogs.js fails after bug 1193394

RESOLVED FIXED in Firefox 60

Status

()

defect
P2
normal
RESOLVED FIXED
2 years ago
4 months ago

People

(Reporter: arai, Assigned: arai)

Tracking

unspecified
mozilla60
Points:
---
Dependency tree / graph

Firefox Tracking Flags

(firefox60 fixed)

Details

Attachments

(1 attachment, 2 obsolete attachments)

https://treeherder.mozilla.org/#/jobs?repo=try&revision=dc889458d9c94fd40e976c572ff37e7556298307&filter-searchStr=bc%20pgo&selectedJob=156297575
> TEST-UNEXPECTED-FAIL | browser/components/preferences/in-content/tests/browser_subdialogs.js | uncaught exception - TypeError: aEvent.target.contentWindow is undefined at _onContentLoaded@chrome://browser/content/preferences/in-content/subdialogs.js:201:1
> TEST-UNEXPECTED-FAIL | browser/components/preferences/in-content/tests/browser_subdialogs.js | No stylesheets that were expected are missing - 4 == 0 -
> TEST-UNEXPECTED-FAIL | browser/components/preferences/in-content/tests/browser_subdialogs.js | Textbox with correct text is focused - "undefined" == "Default text" -
> TEST-UNEXPECTED-FAIL | browser/components/preferences/in-content/tests/browser_subdialogs.js | Test timed out -
> TEST-UNEXPECTED-FAIL | browser/components/preferences/in-content/tests/browser_subdialogs.js | Found a tab after previous test timed out: about:preferences -
05:31:41     INFO -  300 INFO TEST-START | browser/components/preferences/in-content/tests/browser_subdialogs.js
05:31:42     INFO -  TEST-INFO | started process screenshot
05:31:42     INFO -  TEST-INFO | screenshot: exit 0
05:31:42     INFO -  Buffered messages logged at 05:31:41
05:31:42     INFO -  301 INFO Entering test bound test_initialize
05:31:42     INFO -  Buffered messages logged at 05:31:42
05:31:42     INFO -  302 INFO Leaving test bound test_initialize
05:31:42     INFO -  303 INFO Entering test bound check_titlebar_focus_returnval_titlechanges_accepting
05:31:42     INFO -  304 INFO waiting for subdialog DOMFrameContentLoaded
05:31:42     INFO -  Buffered messages finished
05:31:42    ERROR -  305 INFO TEST-UNEXPECTED-FAIL | browser/components/preferences/in-content/tests/browser_subdialogs.js | uncaught exception - TypeError: aEvent.target.contentWindow is undefined at _onContentLoaded@chrome://browser/content/preferences/in-content/subdialogs.js:201:1
05:31:42     INFO -  handleEvent@chrome://browser/content/preferences/in-content/subdialogs.js:175:9
05:31:42     INFO -  EventListener.handleEvent*_addDialogEventListeners@chrome://browser/content/preferences/in-content/subdialogs.js:439:5
05:31:42     INFO -  open@chrome://browser/content/preferences/in-content/subdialogs.js:86:5
05:31:42     INFO -  async*open@chrome://browser/content/preferences/in-content/subdialogs.js:528:5
05:31:42     INFO -  @resource://testing-common/content-task.js line 52 > eval:6:5
05:31:42     INFO -  async*@resource://testing-common/content-task.js:53:20
05:31:42     INFO -  Stack trace:
05:31:42     INFO -  chrome://mochikit/content/tests/SimpleTest/SimpleTest.js:simpletestOnerror:1645
05:31:42     INFO -  GECKO(2420) | JavaScript error: chrome://browser/content/preferences/in-content/subdialogs.js, line 201: TypeError: aEvent.target.contentWindow is undefined
05:31:42     INFO -  306 INFO Console message: [JavaScript Error: "TypeError: aEvent.target.contentWindow is undefined" {file: "chrome://browser/content/preferences/in-content/subdialogs.js" line: 201}]
05:31:42     INFO -  _onContentLoaded@chrome://browser/content/preferences/in-content/subdialogs.js:201:1
05:31:42     INFO -  handleEvent@chrome://browser/content/preferences/in-content/subdialogs.js:175:9
05:31:42     INFO -  EventListener.handleEvent*_addDialogEventListeners@chrome://browser/content/preferences/in-content/subdialogs.js:439:5
05:31:42     INFO -  open@chrome://browser/content/preferences/in-content/subdialogs.js:86:5
05:31:42     INFO -  async*open@chrome://browser/content/preferences/in-content/subdialogs.js:528:5
05:31:42     INFO -  @resource://testing-common/content-task.js line 52 > eval:6:5
05:31:42     INFO -  async*@resource://testing-common/content-task.js:53:20
05:31:42     INFO -  307 INFO waiting for subdialog load
05:31:42     INFO -  308 INFO subdialog window is loaded
05:31:42     INFO -  309 INFO TEST-PASS | browser/components/preferences/in-content/tests/browser_subdialogs.js | The dialog should be non-null - true == true -
05:31:42     INFO -  310 INFO TEST-PASS | browser/components/preferences/in-content/tests/browser_subdialogs.js | Subdialog URL should not be about:blank - "chrome://mochitests/content/browser/browser/components/preferences/in-content/tests/subdialog.xul" != "about:blank" -
05:31:42     INFO -  311 INFO TEST-PASS | browser/components/preferences/in-content/tests/browser_subdialogs.js | Overlay should be visible - "visible" == "visible" -
05:31:42     INFO -  Not taking screenshot here: see the one that was previously logged
05:31:42    ERROR -  312 INFO TEST-UNEXPECTED-FAIL | browser/components/preferences/in-content/tests/browser_subdialogs.js | No stylesheets that were expected are missing - 4 == 0 -
05:31:42     INFO -  Stack trace:
05:31:42     INFO -  resource://testing-common/content-task.js line 52 > eval:null:40
05:31:42     INFO -  313 INFO TEST-PASS | browser/components/preferences/in-content/tests/browser_subdialogs.js | Title should be correct initially - "Sample sub-dialog" == "Sample sub-dialog" -
05:31:42     INFO -  Not taking screenshot here: see the one that was previously logged
05:31:42    ERROR -  314 INFO TEST-UNEXPECTED-FAIL | browser/components/preferences/in-content/tests/browser_subdialogs.js | Textbox with correct text is focused - "undefined" == "Default text" -
05:31:42     INFO -  Stack trace:
05:31:42     INFO -  resource://testing-common/content-task.js line 52 > eval:null:9
05:31:42     INFO -  315 INFO waiting for DOMTitleChanged event
05:31:42     INFO -  316 INFO TEST-PASS | browser/components/preferences/in-content/tests/browser_subdialogs.js | subdialog should have updated title - "Updated title" == "Updated title" -
05:31:42     INFO -  317 INFO waiting for dialogclosing
05:31:42     INFO -  318 INFO waiting for about:blank load
05:32:26     INFO -  Not taking screenshot here: see the one that was previously logged
05:32:26    ERROR -  319 INFO TEST-UNEXPECTED-FAIL | browser/components/preferences/in-content/tests/browser_subdialogs.js | Test timed out -
05:32:26     INFO -  GECKO(2420) | MEMORY STAT | vsize 2276MB | vsizeMaxContiguous 131565905MB | residentFast 512MB | heapAllocated 129MB
05:32:26     INFO -  320 INFO TEST-OK | browser/components/preferences/in-content/tests/browser_subdialogs.js | took 45055ms
05:32:26     INFO -  Not taking screenshot here: see the one that was previously logged
05:32:26    ERROR -  321 INFO TEST-UNEXPECTED-FAIL | browser/components/preferences/in-content/tests/browser_subdialogs.js | Found a tab after previous test timed out: about:preferences -
the error is thrown between those 2 messages
  * waiting for subdialog DOMFrameContentLoaded
  * waiting for subdialog load

so, this area:
https://searchfox.org/mozilla-central/rev/b7e3ec2468d42fa59d86c03ec7afeb209813f1d4/browser/components/preferences/in-content/tests/browser_subdialogs.js#23-37
>     info("waiting for subdialog DOMFrameContentLoaded");
>     let dialogOpenPromise;
>     await new Promise(resolve => {
>       win.addEventListener("DOMFrameContentLoaded", () => {
>         dialogOpenPromise = ContentTaskUtils.waitForEvent(subdialog._overlay, "dialogopen");
>         resolve();
>       }, { once: true, capture: true });
>     });
>     let result;
>     if (args.domcontentloadedFnStr) {
>       // eslint-disable-next-line no-eval
>       result = eval(args.domcontentloadedFnStr);
>     }
> 
>     info("waiting for subdialog load");

and indeed the stack trace for the exception matches DOMFrameContentLoaded.

https://searchfox.org/mozilla-central/rev/b7e3ec2468d42fa59d86c03ec7afeb209813f1d4/browser/components/preferences/in-content/subdialogs.js#200-201
>   _addDialogEventListeners() {
> ...
>     // Similarly DOMFrameContentLoaded only fires on the top window
>     window.addEventListener("DOMFrameContentLoaded", this, true);

https://searchfox.org/mozilla-central/rev/b7e3ec2468d42fa59d86c03ec7afeb209813f1d4/browser/components/preferences/in-content/subdialogs.js#175
>   handleEvent(aEvent) {
>     switch (aEvent.type) {
> ...
>       case "DOMFrameContentLoaded":
>         this._onContentLoaded(aEvent);
>         break;

https://searchfox.org/mozilla-central/rev/b7e3ec2468d42fa59d86c03ec7afeb209813f1d4/browser/components/preferences/in-content/subdialogs.js#200-201
>   _onContentLoaded(aEvent) {
>     if (aEvent.target != this._frame || aEvent.target.contentWindow.location == "about:blank") {
To be clear, this test was failing with different reason before bug 1420310.
but the error is happening outside of the testcase, and the code that triggers DOMFrameContentLoaded is `content.gSubDialog.open(args.url, null, rv);`, that is not touched by bug 1420310.
reproduced locally.
taking
Assignee: nobody → arai.unmht
Status: NEW → ASSIGNED
on failing case, the following properties are `undefined`.
 * contentWindow
 * docShell
 * contentDocument
 * webNavigation
that is clearly wrong, since docShell should be `null` even if not available.

also, contentWindow's "onget" handler is not called when accessing it.
so I think the binding is not used for the case.
maybe not yet loaded or already discarded or something.
I meant this handler
https://searchfox.org/mozilla-central/rev/b7e3ec2468d42fa59d86c03ec7afeb209813f1d4/toolkit/content/widgets/browser.xml#494
>       <property name="contentWindow"
>                 readonly="true"
>                 onget="return this._contentWindow || (this._contentWindow = this.docShell.QueryInterface(Components.interfaces.nsIInterfaceRequestor).getInterface(Components.interfaces.nsIDOMWindow));"/>
apparently the constructor is also not called for the browser.

then, both on successful case and failure case:
  * the constructor is called twice after entering check_titlebar_focus_returnval_titlechanges_accepting
  * DOMFrameContentLoaded event is dispatched twice
  * the 2nd DOMFrameContentLoaded event matches to `aEvent.target != this._frame` condition

then, on successful case, constructor is called twice *before* the 1st DOMFrameContentLoaded event,
but on failure case, constructor is called twice between 1st and 2nd DOMFrameContentLoaded events.

so, apparently DOMFrameContentLoaded is dispatched too early, or the constructor is called too late.
here's backtrace for browser binding constructor and DOMFrameContentLoaded.

==== successful case ====

[browser constructor 1]

0   XUL             0x0000000116ae5208 DumpNativeBacktrace(JSContext*, unsigned int, JS::Value*) + 40
1   XUL             0x00000001168315e5 js::InternalCallOrConstruct(JSContext*, JS::CallArgs const&, js::MaybeConstruct) + 677
2   XUL             0x000000011682c593 Interpret(JSContext*, js::RunState&) + 34227
3   XUL             0x0000000116823e08 js::RunScript(JSContext*, js::RunState&) + 312
4   XUL             0x000000011683172b js::InternalCallOrConstruct(JSContext*, JS::CallArgs const&, js::MaybeConstruct) + 1003
5   XUL             0x00000001168319b9 js::Call(JSContext*, JS::Handle<JS::Value>, JS::Handle<JS::Value>, js::AnyInvokeArgs const&, JS::MutableHandle<JS::Value>) + 41
6   XUL             0x0000000116b5fede JS_CallFunctionValue(JSContext*, JS::Handle<JSObject*>, JS::Handle<JS::Value>, JS::HandleValueArray const&, JS::MutableHandle<JS::Value>) + 398
7   XUL             0x00000001151544bc nsXBLProtoImplAnonymousMethod::Execute(nsIContent*, JSAddonId*) + 780
8   XUL             0x00000001151460fc nsBindingManager::ProcessAttachedQueueInternal(unsigned int) + 156
9   XUL             0x000000011551babf mozilla::PresShell::DoFlushPendingNotifications(mozilla::ChangesToFlush) + 1391
10  XUL             0x00000001154f1af9 nsRefreshDriver::Tick(long long, mozilla::TimeStamp) + 2729
11  XUL             0x00000001154f5831 mozilla::RefreshDriverTimer::TickRefreshDrivers(long long, mozilla::TimeStamp, nsTArray<RefPtr<nsRefreshDriver> >&) + 369
12  XUL             0x00000001154f5657 mozilla::RefreshDriverTimer::Tick(long long, mozilla::TimeStamp) + 135
13  XUL             0x00000001154f63fd mozilla::VsyncRefreshDriverTimer::RefreshDriverVsyncObserver::TickRefreshDriver(mozilla::TimeStamp) + 269
14  XUL             0x00000001154f4b5e mozilla::VsyncRefreshDriverTimer::RefreshDriverVsyncObserver::ParentProcessVsyncNotifier::Run() + 78
15  XUL             0x0000000113260c7a nsThread::ProcessNextEvent(bool, bool*) + 1674
16  XUL             0x0000000113269549 NS_ProcessPendingEvents(nsIThread*, unsigned int) + 73
17  XUL             0x00000001152964c1 nsBaseAppShell::NativeEventCallback() + 113
18  XUL             0x00000001152ec9f8 nsAppShell::ProcessGeckoEvents(void*) + 248
19  CoreFoundation  0x00007fffa5ec7321 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 17
20  CoreFoundation  0x00007fffa5ea8197 __CFRunLoopDoSources0 + 423
21  CoreFoundation  0x00007fffa5ea7716 __CFRunLoopRun + 934
22  CoreFoundation  0x00007fffa5ea7114 CFRunLoopRunSpecific + 420
23  HIToolbox       0x00007fffa5407ebc RunCurrentEventLoopInMode + 240
24  HIToolbox       0x00007fffa5407cf1 ReceiveNextEventCommon + 432
25  HIToolbox       0x00007fffa5407b26 _BlockUntilNextEventMatchingListInModeWithFilter + 71
26  AppKit          0x00007fffa399ea54 _DPSNextEvent + 1120
27  AppKit          0x00007fffa411a7ee -[NSApplication(NSEvent) _nextEventMatchingEventMask:untilDate:inMode:dequeue:] + 2796
28  XUL             0x00000001152ec076 -[GeckoNSApplication nextEventMatchingMask:untilDate:inMode:dequeue:] + 86
29  AppKit          0x00007fffa39933db -[NSApplication run] + 926
30  XUL             0x00000001152ecf27 nsAppShell::Run() + 247
31  XUL             0x000000011665cd24 nsAppStartup::Run() + 68
32  XUL             0x000000011670889a XREMain::XRE_mainRun() + 3578
33  XUL             0x0000000116709109 XREMain::XRE_main(int, char**, mozilla::BootstrapConfig const&) + 1065
34  XUL             0x0000000116709683 XRE_main(int, char**, mozilla::BootstrapConfig const&) + 227
35  firefox         0x000000010d466026 main + 822
36  firefox         0x000000010d465cc4 start + 52
37  ???             0x0000000000000005 0x0 + 5

[browser constructor 2]

0   XUL             0x0000000116ae5208 DumpNativeBacktrace(JSContext*, unsigned int, JS::Value*) + 40
1   XUL             0x00000001168315e5 js::InternalCallOrConstruct(JSContext*, JS::CallArgs const&, js::MaybeConstruct) + 677
2   XUL             0x000000011682c593 Interpret(JSContext*, js::RunState&) + 34227
3   XUL             0x0000000116823e08 js::RunScript(JSContext*, js::RunState&) + 312
4   XUL             0x000000011683172b js::InternalCallOrConstruct(JSContext*, JS::CallArgs const&, js::MaybeConstruct) + 1003
5   XUL             0x00000001168319b9 js::Call(JSContext*, JS::Handle<JS::Value>, JS::Handle<JS::Value>, js::AnyInvokeArgs const&, JS::MutableHandle<JS::Value>) + 41
6   XUL             0x0000000116b5fede JS_CallFunctionValue(JSContext*, JS::Handle<JSObject*>, JS::Handle<JS::Value>, JS::HandleValueArray const&, JS::MutableHandle<JS::Value>) + 398
7   XUL             0x00000001151544bc nsXBLProtoImplAnonymousMethod::Execute(nsIContent*, JSAddonId*) + 780
8   XUL             0x00000001151460fc nsBindingManager::ProcessAttachedQueueInternal(unsigned int) + 156
9   XUL             0x000000011551babf mozilla::PresShell::DoFlushPendingNotifications(mozilla::ChangesToFlush) + 1391
10  XUL             0x00000001154f1af9 nsRefreshDriver::Tick(long long, mozilla::TimeStamp) + 2729
11  XUL             0x00000001154f5831 mozilla::RefreshDriverTimer::TickRefreshDrivers(long long, mozilla::TimeStamp, nsTArray<RefPtr<nsRefreshDriver> >&) + 369
12  XUL             0x00000001154f5657 mozilla::RefreshDriverTimer::Tick(long long, mozilla::TimeStamp) + 135
13  XUL             0x00000001154f63fd mozilla::VsyncRefreshDriverTimer::RefreshDriverVsyncObserver::TickRefreshDriver(mozilla::TimeStamp) + 269
14  XUL             0x00000001154f4b5e mozilla::VsyncRefreshDriverTimer::RefreshDriverVsyncObserver::ParentProcessVsyncNotifier::Run() + 78
15  XUL             0x0000000113260c7a nsThread::ProcessNextEvent(bool, bool*) + 1674
16  XUL             0x0000000113269549 NS_ProcessPendingEvents(nsIThread*, unsigned int) + 73
17  XUL             0x00000001152964c1 nsBaseAppShell::NativeEventCallback() + 113
18  XUL             0x00000001152ec9f8 nsAppShell::ProcessGeckoEvents(void*) + 248
19  CoreFoundation  0x00007fffa5ec7321 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 17
20  CoreFoundation  0x00007fffa5ea8197 __CFRunLoopDoSources0 + 423
21  CoreFoundation  0x00007fffa5ea7716 __CFRunLoopRun + 934
22  CoreFoundation  0x00007fffa5ea7114 CFRunLoopRunSpecific + 420
23  HIToolbox       0x00007fffa5407ebc RunCurrentEventLoopInMode + 240
24  HIToolbox       0x00007fffa5407cf1 ReceiveNextEventCommon + 432
25  HIToolbox       0x00007fffa5407b26 _BlockUntilNextEventMatchingListInModeWithFilter + 71
26  AppKit          0x00007fffa399ea54 _DPSNextEvent + 1120
27  AppKit          0x00007fffa411a7ee -[NSApplication(NSEvent) _nextEventMatchingEventMask:untilDate:inMode:dequeue:] + 2796
28  XUL             0x00000001152ec076 -[GeckoNSApplication nextEventMatchingMask:untilDate:inMode:dequeue:] + 86
29  AppKit          0x00007fffa39933db -[NSApplication run] + 926
30  XUL             0x00000001152ecf27 nsAppShell::Run() + 247
31  XUL             0x000000011665cd24 nsAppStartup::Run() + 68
32  XUL             0x000000011670889a XREMain::XRE_mainRun() + 3578
33  XUL             0x0000000116709109 XREMain::XRE_main(int, char**, mozilla::BootstrapConfig const&) + 1065
34  XUL             0x0000000116709683 XRE_main(int, char**, mozilla::BootstrapConfig const&) + 227
35  firefox         0x000000010d466026 main + 822
36  firefox         0x000000010d465cc4 start + 52
37  ???             0x0000000000000005 0x0 + 5

[DOMFrameContentLoaded 1]

0   XUL             0x0000000116ae5208 DumpNativeBacktrace(JSContext*, unsigned int, JS::Value*) + 40
1   XUL             0x00000001168315e5 js::InternalCallOrConstruct(JSContext*, JS::CallArgs const&, js::MaybeConstruct) + 677
2   XUL             0x000000011682c593 Interpret(JSContext*, js::RunState&) + 34227
3   XUL             0x0000000116823e08 js::RunScript(JSContext*, js::RunState&) + 312
4   XUL             0x000000011683172b js::InternalCallOrConstruct(JSContext*, JS::CallArgs const&, js::MaybeConstruct) + 1003
5   XUL             0x000000011682c593 Interpret(JSContext*, js::RunState&) + 34227
6   XUL             0x0000000116823e08 js::RunScript(JSContext*, js::RunState&) + 312
7   XUL             0x000000011683172b js::InternalCallOrConstruct(JSContext*, JS::CallArgs const&, js::MaybeConstruct) + 1003
8   XUL             0x00000001168319b9 js::Call(JSContext*, JS::Handle<JS::Value>, JS::Handle<JS::Value>, js::AnyInvokeArgs const&, JS::MutableHandle<JS::Value>) + 41
9   XUL             0x0000000116b6087a JS::Call(JSContext*, JS::Handle<JS::Value>, JS::Handle<JS::Value>, JS::HandleValueArray const&, JS::MutableHandle<JS::Value>) + 298
10  XUL             0x0000000114774d03 mozilla::dom::EventListener::HandleEvent(JSContext*, JS::Handle<JS::Value>, mozilla::dom::Event&, mozilla::ErrorResult&) + 691
11  XUL             0x0000000114aa22eb mozilla::EventListenerManager::HandleEventSubType(mozilla::EventListenerManager::Listener*, nsIDOMEvent*, mozilla::dom::EventTarget*) + 331
12  XUL             0x0000000114aa2e13 mozilla::EventListenerManager::HandleEventInternal(nsPresContext*, mozilla::WidgetEvent*, nsIDOMEvent**, mozilla::dom::EventTarget*, nsEventStatus*) + 2643
13  XUL             0x0000000114a9c1ec mozilla::EventTargetChainItem::HandleEventTargetChain(nsTArray<mozilla::EventTargetChainItem>&, mozilla::EventChainPostVisitor&, mozilla::EventDispatchingCallback*, mozilla::ELMCreationDetector&) + 268
14  XUL             0x0000000114a9d3a9 mozilla::EventDispatcher::Dispatch(nsISupports*, nsPresContext*, mozilla::WidgetEvent*, nsIDOMEvent*, nsEventStatus*, mozilla::EventDispatchingCallback*, nsTArray<mozilla::dom::EventTarget*>*) + 2665
15  XUL             0x000000011415d87d nsDocument::DispatchContentLoadedEvents() + 573
16  XUL             0x00000001151bba10 mozilla::dom::XULDocument::DoneWalking() + 1216
17  XUL             0x00000001151bbda6 non-virtual thunk to mozilla::dom::XULDocument::StyleSheetLoaded(mozilla::StyleSheet*, bool, nsresult) + 38
18  XUL             0x00000001153ec729 mozilla::css::Loader::SheetComplete(mozilla::css::SheetLoadData*, nsresult) + 345
19  XUL             0x00000001153e944f mozilla::css::SheetLoadData::Run() + 111
20  XUL             0x0000000113260c7a nsThread::ProcessNextEvent(bool, bool*) + 1674
21  XUL             0x0000000113269549 NS_ProcessPendingEvents(nsIThread*, unsigned int) + 73
22  XUL             0x00000001152964c1 nsBaseAppShell::NativeEventCallback() + 113
23  XUL             0x00000001152ec9f8 nsAppShell::ProcessGeckoEvents(void*) + 248
24  CoreFoundation  0x00007fffa5ec7321 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 17
25  CoreFoundation  0x00007fffa5ea8197 __CFRunLoopDoSources0 + 423
26  CoreFoundation  0x00007fffa5ea7716 __CFRunLoopRun + 934
27  CoreFoundation  0x00007fffa5ea7114 CFRunLoopRunSpecific + 420
28  HIToolbox       0x00007fffa5407ebc RunCurrentEventLoopInMode + 240
29  HIToolbox       0x00007fffa5407cf1 ReceiveNextEventCommon + 432
30  HIToolbox       0x00007fffa5407b26 _BlockUntilNextEventMatchingListInModeWithFilter + 71
31  AppKit          0x00007fffa399ea54 _DPSNextEvent + 1120
32  AppKit          0x00007fffa411a7ee -[NSApplication(NSEvent) _nextEventMatchingEventMask:untilDate:inMode:dequeue:] + 2796
33  XUL             0x00000001152ec076 -[GeckoNSApplication nextEventMatchingMask:untilDate:inMode:dequeue:] + 86
34  AppKit          0x00007fffa39933db -[NSApplication run] + 926
35  XUL             0x00000001152ecf27 nsAppShell::Run() + 247
36  XUL             0x000000011665cd24 nsAppStartup::Run() + 68
37  XUL             0x000000011670889a XREMain::XRE_mainRun() + 3578
38  XUL             0x0000000116709109 XREMain::XRE_main(int, char**, mozilla::BootstrapConfig const&) + 1065
39  XUL             0x0000000116709683 XRE_main(int, char**, mozilla::BootstrapConfig const&) + 227
40  firefox         0x000000010d466026 main + 822
41  firefox         0x000000010d465cc4 start + 52
42  ???             0x0000000000000005 0x0 + 5

[DOMFrameContentLoaded 2]

0   XUL             0x0000000116ae5208 DumpNativeBacktrace(JSContext*, unsigned int, JS::Value*) + 40
1   XUL             0x00000001168315e5 js::InternalCallOrConstruct(JSContext*, JS::CallArgs const&, js::MaybeConstruct) + 677
2   XUL             0x000000011682c593 Interpret(JSContext*, js::RunState&) + 34227
3   XUL             0x0000000116823e08 js::RunScript(JSContext*, js::RunState&) + 312
4   XUL             0x000000011683172b js::InternalCallOrConstruct(JSContext*, JS::CallArgs const&, js::MaybeConstruct) + 1003
5   XUL             0x000000011682c593 Interpret(JSContext*, js::RunState&) + 34227
6   XUL             0x0000000116823e08 js::RunScript(JSContext*, js::RunState&) + 312
7   XUL             0x000000011683172b js::InternalCallOrConstruct(JSContext*, JS::CallArgs const&, js::MaybeConstruct) + 1003
8   XUL             0x00000001168319b9 js::Call(JSContext*, JS::Handle<JS::Value>, JS::Handle<JS::Value>, js::AnyInvokeArgs const&, JS::MutableHandle<JS::Value>) + 41
9   XUL             0x0000000116b6087a JS::Call(JSContext*, JS::Handle<JS::Value>, JS::Handle<JS::Value>, JS::HandleValueArray const&, JS::MutableHandle<JS::Value>) + 298
10  XUL             0x0000000114774d03 mozilla::dom::EventListener::HandleEvent(JSContext*, JS::Handle<JS::Value>, mozilla::dom::Event&, mozilla::ErrorResult&) + 691
11  XUL             0x0000000114aa22eb mozilla::EventListenerManager::HandleEventSubType(mozilla::EventListenerManager::Listener*, nsIDOMEvent*, mozilla::dom::EventTarget*) + 331
12  XUL             0x0000000114aa2e13 mozilla::EventListenerManager::HandleEventInternal(nsPresContext*, mozilla::WidgetEvent*, nsIDOMEvent**, mozilla::dom::EventTarget*, nsEventStatus*) + 2643
13  XUL             0x0000000114a9c1ec mozilla::EventTargetChainItem::HandleEventTargetChain(nsTArray<mozilla::EventTargetChainItem>&, mozilla::EventChainPostVisitor&, mozilla::EventDispatchingCallback*, mozilla::ELMCreationDetector&) + 268
14  XUL             0x0000000114a9d3a9 mozilla::EventDispatcher::Dispatch(nsISupports*, nsPresContext*, mozilla::WidgetEvent*, nsIDOMEvent*, nsEventStatus*, mozilla::EventDispatchingCallback*, nsTArray<mozilla::dom::EventTarget*>*) + 2665
15  XUL             0x000000011415d87d nsDocument::DispatchContentLoadedEvents() + 573
16  XUL             0x000000011417e987 mozilla::detail::RunnableMethodImpl<nsDocument*, void (nsDocument::*)(), true, (mozilla::RunnableKind)0>::Run() + 39
17  XUL             0x0000000113260c7a nsThread::ProcessNextEvent(bool, bool*) + 1674
18  XUL             0x0000000113269549 NS_ProcessPendingEvents(nsIThread*, unsigned int) + 73
19  XUL             0x00000001152964c1 nsBaseAppShell::NativeEventCallback() + 113
20  XUL             0x00000001152ec9f8 nsAppShell::ProcessGeckoEvents(void*) + 248
21  CoreFoundation  0x00007fffa5ec7321 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 17
22  CoreFoundation  0x00007fffa5ea8197 __CFRunLoopDoSources0 + 423
23  CoreFoundation  0x00007fffa5ea7716 __CFRunLoopRun + 934
24  CoreFoundation  0x00007fffa5ea7114 CFRunLoopRunSpecific + 420
25  HIToolbox       0x00007fffa5407ebc RunCurrentEventLoopInMode + 240
26  HIToolbox       0x00007fffa5407cf1 ReceiveNextEventCommon + 432
27  HIToolbox       0x00007fffa5407b26 _BlockUntilNextEventMatchingListInModeWithFilter + 71
28  AppKit          0x00007fffa399ea54 _DPSNextEvent + 1120
29  AppKit          0x00007fffa411a7ee -[NSApplication(NSEvent) _nextEventMatchingEventMask:untilDate:inMode:dequeue:] + 2796
30  XUL             0x00000001152ec076 -[GeckoNSApplication nextEventMatchingMask:untilDate:inMode:dequeue:] + 86
31  AppKit          0x00007fffa39933db -[NSApplication run] + 926
32  XUL             0x00000001152ecf27 nsAppShell::Run() + 247
33  XUL             0x000000011665cd24 nsAppStartup::Run() + 68
34  XUL             0x000000011670889a XREMain::XRE_mainRun() + 3578
35  XUL             0x0000000116709109 XREMain::XRE_main(int, char**, mozilla::BootstrapConfig const&) + 1065
36  XUL             0x0000000116709683 XRE_main(int, char**, mozilla::BootstrapConfig const&) + 227
37  firefox         0x000000010d466026 main + 822
38  firefox         0x000000010d465cc4 start + 52
39  ???             0x0000000000000005 0x0 + 5

==== failure case ====

[DOMFrameContentLoaded 1]

0   XUL             0x0000000116ae5208 DumpNativeBacktrace(JSContext*, unsigned int, JS::Value*) + 40
1   XUL             0x00000001168315e5 js::InternalCallOrConstruct(JSContext*, JS::CallArgs const&, js::MaybeConstruct) + 677
2   XUL             0x000000011682c593 Interpret(JSContext*, js::RunState&) + 34227
3   XUL             0x0000000116823e08 js::RunScript(JSContext*, js::RunState&) + 312
4   XUL             0x000000011683172b js::InternalCallOrConstruct(JSContext*, JS::CallArgs const&, js::MaybeConstruct) + 1003
5   XUL             0x000000011682c593 Interpret(JSContext*, js::RunState&) + 34227
6   XUL             0x0000000116823e08 js::RunScript(JSContext*, js::RunState&) + 312
7   XUL             0x000000011683172b js::InternalCallOrConstruct(JSContext*, JS::CallArgs const&, js::MaybeConstruct) + 1003
8   XUL             0x00000001168319b9 js::Call(JSContext*, JS::Handle<JS::Value>, JS::Handle<JS::Value>, js::AnyInvokeArgs const&, JS::MutableHandle<JS::Value>) + 41
9   XUL             0x0000000116b6087a JS::Call(JSContext*, JS::Handle<JS::Value>, JS::Handle<JS::Value>, JS::HandleValueArray const&, JS::MutableHandle<JS::Value>) + 298
10  XUL             0x0000000114774d03 mozilla::dom::EventListener::HandleEvent(JSContext*, JS::Handle<JS::Value>, mozilla::dom::Event&, mozilla::ErrorResult&) + 691
11  XUL             0x0000000114aa22eb mozilla::EventListenerManager::HandleEventSubType(mozilla::EventListenerManager::Listener*, nsIDOMEvent*, mozilla::dom::EventTarget*) + 331
12  XUL             0x0000000114aa2e13 mozilla::EventListenerManager::HandleEventInternal(nsPresContext*, mozilla::WidgetEvent*, nsIDOMEvent**, mozilla::dom::EventTarget*, nsEventStatus*) + 2643
13  XUL             0x0000000114a9c1ec mozilla::EventTargetChainItem::HandleEventTargetChain(nsTArray<mozilla::EventTargetChainItem>&, mozilla::EventChainPostVisitor&, mozilla::EventDispatchingCallback*, mozilla::ELMCreationDetector&) + 268
14  XUL             0x0000000114a9d3a9 mozilla::EventDispatcher::Dispatch(nsISupports*, nsPresContext*, mozilla::WidgetEvent*, nsIDOMEvent*, nsEventStatus*, mozilla::EventDispatchingCallback*, nsTArray<mozilla::dom::EventTarget*>*) + 2665
15  XUL             0x000000011415d87d nsDocument::DispatchContentLoadedEvents() + 573
16  XUL             0x00000001151bba10 mozilla::dom::XULDocument::DoneWalking() + 1216
17  XUL             0x00000001151bbda6 non-virtual thunk to mozilla::dom::XULDocument::StyleSheetLoaded(mozilla::StyleSheet*, bool, nsresult) + 38
18  XUL             0x00000001153ec729 mozilla::css::Loader::SheetComplete(mozilla::css::SheetLoadData*, nsresult) + 345
19  XUL             0x00000001153e944f mozilla::css::SheetLoadData::Run() + 111
20  XUL             0x0000000113260c7a nsThread::ProcessNextEvent(bool, bool*) + 1674
21  XUL             0x0000000113269549 NS_ProcessPendingEvents(nsIThread*, unsigned int) + 73
22  XUL             0x00000001152964c1 nsBaseAppShell::NativeEventCallback() + 113
23  XUL             0x00000001152ec9f8 nsAppShell::ProcessGeckoEvents(void*) + 248
24  CoreFoundation  0x00007fffa5ec7321 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 17
25  CoreFoundation  0x00007fffa5ea8197 __CFRunLoopDoSources0 + 423
26  CoreFoundation  0x00007fffa5ea7716 __CFRunLoopRun + 934
27  CoreFoundation  0x00007fffa5ea7114 CFRunLoopRunSpecific + 420
28  HIToolbox       0x00007fffa5407ebc RunCurrentEventLoopInMode + 240
29  HIToolbox       0x00007fffa5407cf1 ReceiveNextEventCommon + 432
30  HIToolbox       0x00007fffa5407b26 _BlockUntilNextEventMatchingListInModeWithFilter + 71
31  AppKit          0x00007fffa399ea54 _DPSNextEvent + 1120
32  AppKit          0x00007fffa411a7ee -[NSApplication(NSEvent) _nextEventMatchingEventMask:untilDate:inMode:dequeue:] + 2796
33  XUL             0x00000001152ec076 -[GeckoNSApplication nextEventMatchingMask:untilDate:inMode:dequeue:] + 86
34  AppKit          0x00007fffa39933db -[NSApplication run] + 926
35  XUL             0x00000001152ecf27 nsAppShell::Run() + 247
36  XUL             0x000000011665cd24 nsAppStartup::Run() + 68
37  XUL             0x000000011670889a XREMain::XRE_mainRun() + 3578
38  XUL             0x0000000116709109 XREMain::XRE_main(int, char**, mozilla::BootstrapConfig const&) + 1065
39  XUL             0x0000000116709683 XRE_main(int, char**, mozilla::BootstrapConfig const&) + 227
40  firefox         0x000000010d466026 main + 822
41  firefox         0x000000010d465cc4 start + 52
42  ???             0x0000000000000005 0x0 + 5

[browser constructor 1]

0   XUL             0x0000000116ae5208 DumpNativeBacktrace(JSContext*, unsigned int, JS::Value*) + 40
1   XUL             0x00000001168315e5 js::InternalCallOrConstruct(JSContext*, JS::CallArgs const&, js::MaybeConstruct) + 677
2   XUL             0x000000011682c593 Interpret(JSContext*, js::RunState&) + 34227
3   XUL             0x0000000116823e08 js::RunScript(JSContext*, js::RunState&) + 312
4   XUL             0x000000011683172b js::InternalCallOrConstruct(JSContext*, JS::CallArgs const&, js::MaybeConstruct) + 1003
5   XUL             0x00000001168319b9 js::Call(JSContext*, JS::Handle<JS::Value>, JS::Handle<JS::Value>, js::AnyInvokeArgs const&, JS::MutableHandle<JS::Value>) + 41
6   XUL             0x0000000116b5fede JS_CallFunctionValue(JSContext*, JS::Handle<JSObject*>, JS::Handle<JS::Value>, JS::HandleValueArray const&, JS::MutableHandle<JS::Value>) + 398
7   XUL             0x00000001151544bc nsXBLProtoImplAnonymousMethod::Execute(nsIContent*, JSAddonId*) + 780
8   XUL             0x00000001151460fc nsBindingManager::ProcessAttachedQueueInternal(unsigned int) + 156
9   XUL             0x000000011551babf mozilla::PresShell::DoFlushPendingNotifications(mozilla::ChangesToFlush) + 1391
10  XUL             0x0000000114165245 nsDocument::FlushPendingNotifications(mozilla::FlushType, mozilla::FlushTarget) + 421
11  XUL             0x00000001141651da nsDocument::FlushPendingNotifications(mozilla::FlushType, mozilla::FlushTarget) + 314
12  XUL             0x0000000113c074a8 nsDocLoader::DocLoaderIsEmpty(bool) + 216
13  XUL             0x0000000113c07f2d nsDocLoader::OnStopRequest(nsIRequest*, nsISupports*, nsresult) + 845
14  XUL             0x0000000113c0822d non-virtual thunk to nsDocLoader::OnStopRequest(nsIRequest*, nsISupports*, nsresult) + 13
15  XUL             0x00000001132eb5fb mozilla::net::nsLoadGroup::RemoveRequest(nsIRequest*, nsISupports*, nsresult) + 939
16  XUL             0x0000000114166f0b nsDocument::DoUnblockOnload() + 283
17  XUL             0x00000001153e9466 mozilla::css::SheetLoadData::Run() + 134
18  XUL             0x0000000113260c7a nsThread::ProcessNextEvent(bool, bool*) + 1674
19  XUL             0x0000000113269549 NS_ProcessPendingEvents(nsIThread*, unsigned int) + 73
20  XUL             0x00000001152964c1 nsBaseAppShell::NativeEventCallback() + 113
21  XUL             0x00000001152ec9f8 nsAppShell::ProcessGeckoEvents(void*) + 248
22  CoreFoundation  0x00007fffa5ec7321 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 17
23  CoreFoundation  0x00007fffa5ea8197 __CFRunLoopDoSources0 + 423
24  CoreFoundation  0x00007fffa5ea7716 __CFRunLoopRun + 934
25  CoreFoundation  0x00007fffa5ea7114 CFRunLoopRunSpecific + 420
26  HIToolbox       0x00007fffa5407ebc RunCurrentEventLoopInMode + 240
27  HIToolbox       0x00007fffa5407cf1 ReceiveNextEventCommon + 432
28  HIToolbox       0x00007fffa5407b26 _BlockUntilNextEventMatchingListInModeWithFilter + 71
29  AppKit          0x00007fffa399ea54 _DPSNextEvent + 1120
30  AppKit          0x00007fffa411a7ee -[NSApplication(NSEvent) _nextEventMatchingEventMask:untilDate:inMode:dequeue:] + 2796
31  XUL             0x00000001152ec076 -[GeckoNSApplication nextEventMatchingMask:untilDate:inMode:dequeue:] + 86
32  AppKit          0x00007fffa39933db -[NSApplication run] + 926
33  XUL             0x00000001152ecf27 nsAppShell::Run() + 247
34  XUL             0x000000011665cd24 nsAppStartup::Run() + 68
35  XUL             0x000000011670889a XREMain::XRE_mainRun() + 3578
36  XUL             0x0000000116709109 XREMain::XRE_main(int, char**, mozilla::BootstrapConfig const&) + 1065
37  XUL             0x0000000116709683 XRE_main(int, char**, mozilla::BootstrapConfig const&) + 227
38  firefox         0x000000010d466026 main + 822
39  firefox         0x000000010d465cc4 start + 52
40  ???             0x0000000000000005 0x0 + 5

[browser constructor 2]

0   XUL             0x0000000116ae5208 DumpNativeBacktrace(JSContext*, unsigned int, JS::Value*) + 40
1   XUL             0x00000001168315e5 js::InternalCallOrConstruct(JSContext*, JS::CallArgs const&, js::MaybeConstruct) + 677
2   XUL             0x000000011682c593 Interpret(JSContext*, js::RunState&) + 34227
3   XUL             0x0000000116823e08 js::RunScript(JSContext*, js::RunState&) + 312
4   XUL             0x000000011683172b js::InternalCallOrConstruct(JSContext*, JS::CallArgs const&, js::MaybeConstruct) + 1003
5   XUL             0x00000001168319b9 js::Call(JSContext*, JS::Handle<JS::Value>, JS::Handle<JS::Value>, js::AnyInvokeArgs const&, JS::MutableHandle<JS::Value>) + 41
6   XUL             0x0000000116b5fede JS_CallFunctionValue(JSContext*, JS::Handle<JSObject*>, JS::Handle<JS::Value>, JS::HandleValueArray const&, JS::MutableHandle<JS::Value>) + 398
7   XUL             0x00000001151544bc nsXBLProtoImplAnonymousMethod::Execute(nsIContent*, JSAddonId*) + 780
8   XUL             0x00000001151460fc nsBindingManager::ProcessAttachedQueueInternal(unsigned int) + 156
9   XUL             0x000000011551babf mozilla::PresShell::DoFlushPendingNotifications(mozilla::ChangesToFlush) + 1391
10  XUL             0x0000000114165245 nsDocument::FlushPendingNotifications(mozilla::FlushType, mozilla::FlushTarget) + 421
11  XUL             0x00000001141651da nsDocument::FlushPendingNotifications(mozilla::FlushType, mozilla::FlushTarget) + 314
12  XUL             0x0000000113c074a8 nsDocLoader::DocLoaderIsEmpty(bool) + 216
13  XUL             0x0000000113c07f2d nsDocLoader::OnStopRequest(nsIRequest*, nsISupports*, nsresult) + 845
14  XUL             0x0000000113c0822d non-virtual thunk to nsDocLoader::OnStopRequest(nsIRequest*, nsISupports*, nsresult) + 13
15  XUL             0x00000001132eb5fb mozilla::net::nsLoadGroup::RemoveRequest(nsIRequest*, nsISupports*, nsresult) + 939
16  XUL             0x0000000114166f0b nsDocument::DoUnblockOnload() + 283
17  XUL             0x00000001153e9466 mozilla::css::SheetLoadData::Run() + 134
18  XUL             0x0000000113260c7a nsThread::ProcessNextEvent(bool, bool*) + 1674
19  XUL             0x0000000113269549 NS_ProcessPendingEvents(nsIThread*, unsigned int) + 73
20  XUL             0x00000001152964c1 nsBaseAppShell::NativeEventCallback() + 113
21  XUL             0x00000001152ec9f8 nsAppShell::ProcessGeckoEvents(void*) + 248
22  CoreFoundation  0x00007fffa5ec7321 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 17
23  CoreFoundation  0x00007fffa5ea8197 __CFRunLoopDoSources0 + 423
24  CoreFoundation  0x00007fffa5ea7716 __CFRunLoopRun + 934
25  CoreFoundation  0x00007fffa5ea7114 CFRunLoopRunSpecific + 420
26  HIToolbox       0x00007fffa5407ebc RunCurrentEventLoopInMode + 240
27  HIToolbox       0x00007fffa5407cf1 ReceiveNextEventCommon + 432
28  HIToolbox       0x00007fffa5407b26 _BlockUntilNextEventMatchingListInModeWithFilter + 71
29  AppKit          0x00007fffa399ea54 _DPSNextEvent + 1120
30  AppKit          0x00007fffa411a7ee -[NSApplication(NSEvent) _nextEventMatchingEventMask:untilDate:inMode:dequeue:] + 2796
31  XUL             0x00000001152ec076 -[GeckoNSApplication nextEventMatchingMask:untilDate:inMode:dequeue:] + 86
32  AppKit          0x00007fffa39933db -[NSApplication run] + 926
33  XUL             0x00000001152ecf27 nsAppShell::Run() + 247
34  XUL             0x000000011665cd24 nsAppStartup::Run() + 68
35  XUL             0x000000011670889a XREMain::XRE_mainRun() + 3578
36  XUL             0x0000000116709109 XREMain::XRE_main(int, char**, mozilla::BootstrapConfig const&) + 1065
37  XUL             0x0000000116709683 XRE_main(int, char**, mozilla::BootstrapConfig const&) + 227
38  firefox         0x000000010d466026 main + 822
39  firefox         0x000000010d465cc4 start + 52
40  ???             0x0000000000000005 0x0 + 5

[DOMFrameContentLoaded 2]

0   XUL             0x0000000116ae5208 DumpNativeBacktrace(JSContext*, unsigned int, JS::Value*) + 40
1   XUL             0x00000001168315e5 js::InternalCallOrConstruct(JSContext*, JS::CallArgs const&, js::MaybeConstruct) + 677
2   XUL             0x000000011682c593 Interpret(JSContext*, js::RunState&) + 34227
3   XUL             0x0000000116823e08 js::RunScript(JSContext*, js::RunState&) + 312
4   XUL             0x000000011683172b js::InternalCallOrConstruct(JSContext*, JS::CallArgs const&, js::MaybeConstruct) + 1003
5   XUL             0x000000011682c593 Interpret(JSContext*, js::RunState&) + 34227
6   XUL             0x0000000116823e08 js::RunScript(JSContext*, js::RunState&) + 312
7   XUL             0x000000011683172b js::InternalCallOrConstruct(JSContext*, JS::CallArgs const&, js::MaybeConstruct) + 1003
8   XUL             0x00000001168319b9 js::Call(JSContext*, JS::Handle<JS::Value>, JS::Handle<JS::Value>, js::AnyInvokeArgs const&, JS::MutableHandle<JS::Value>) + 41
9   XUL             0x0000000116b6087a JS::Call(JSContext*, JS::Handle<JS::Value>, JS::Handle<JS::Value>, JS::HandleValueArray const&, JS::MutableHandle<JS::Value>) + 298
10  XUL             0x0000000114774d03 mozilla::dom::EventListener::HandleEvent(JSContext*, JS::Handle<JS::Value>, mozilla::dom::Event&, mozilla::ErrorResult&) + 691
11  XUL             0x0000000114aa22eb mozilla::EventListenerManager::HandleEventSubType(mozilla::EventListenerManager::Listener*, nsIDOMEvent*, mozilla::dom::EventTarget*) + 331
12  XUL             0x0000000114aa2e13 mozilla::EventListenerManager::HandleEventInternal(nsPresContext*, mozilla::WidgetEvent*, nsIDOMEvent**, mozilla::dom::EventTarget*, nsEventStatus*) + 2643
13  XUL             0x0000000114a9c1ec mozilla::EventTargetChainItem::HandleEventTargetChain(nsTArray<mozilla::EventTargetChainItem>&, mozilla::EventChainPostVisitor&, mozilla::EventDispatchingCallback*, mozilla::ELMCreationDetector&) + 268
14  XUL             0x0000000114a9d3a9 mozilla::EventDispatcher::Dispatch(nsISupports*, nsPresContext*, mozilla::WidgetEvent*, nsIDOMEvent*, nsEventStatus*, mozilla::EventDispatchingCallback*, nsTArray<mozilla::dom::EventTarget*>*) + 2665
15  XUL             0x000000011415d87d nsDocument::DispatchContentLoadedEvents() + 573
16  XUL             0x000000011417e987 mozilla::detail::RunnableMethodImpl<nsDocument*, void (nsDocument::*)(), true, (mozilla::RunnableKind)0>::Run() + 39
17  XUL             0x0000000113260c7a nsThread::ProcessNextEvent(bool, bool*) + 1674
18  XUL             0x0000000113269549 NS_ProcessPendingEvents(nsIThread*, unsigned int) + 73
19  XUL             0x00000001152964c1 nsBaseAppShell::NativeEventCallback() + 113
20  XUL             0x00000001152ec9f8 nsAppShell::ProcessGeckoEvents(void*) + 248
21  CoreFoundation  0x00007fffa5ec7321 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 17
22  CoreFoundation  0x00007fffa5ea8197 __CFRunLoopDoSources0 + 423
23  CoreFoundation  0x00007fffa5ea7716 __CFRunLoopRun + 934
24  CoreFoundation  0x00007fffa5ea7114 CFRunLoopRunSpecific + 420
25  HIToolbox       0x00007fffa5407ebc RunCurrentEventLoopInMode + 240
26  HIToolbox       0x00007fffa5407cf1 ReceiveNextEventCommon + 432
27  HIToolbox       0x00007fffa5407b26 _BlockUntilNextEventMatchingListInModeWithFilter + 71
28  AppKit          0x00007fffa399ea54 _DPSNextEvent + 1120
29  AppKit          0x00007fffa411a7ee -[NSApplication(NSEvent) _nextEventMatchingEventMask:untilDate:inMode:dequeue:] + 2796
30  XUL             0x00000001152ec076 -[GeckoNSApplication nextEventMatchingMask:untilDate:inMode:dequeue:] + 86
31  AppKit          0x00007fffa39933db -[NSApplication run] + 926
32  XUL             0x00000001152ecf27 nsAppShell::Run() + 247
33  XUL             0x000000011665cd24 nsAppStartup::Run() + 68
34  XUL             0x000000011670889a XREMain::XRE_mainRun() + 3578
35  XUL             0x0000000116709109 XREMain::XRE_main(int, char**, mozilla::BootstrapConfig const&) + 1065
36  XUL             0x0000000116709683 XRE_main(int, char**, mozilla::BootstrapConfig const&) + 227
37  firefox         0x000000010d466026 main + 822
38  firefox         0x000000010d465cc4 start + 52
39  ???             0x0000000000000005 0x0 + 5
so, on successful case, browser binding constructor is called by
mozilla::VsyncRefreshDriverTimer::RefreshDriverVsyncObserver::ParentProcessVsyncNotifier::Run

and on failure case, it's called by mozilla::css::SheetLoadData::Run
Component: General → XBL
Product: Firefox → Core
on failure case, constructor is executed in `mDocument->UnblockOnload`, and DOMFrameContentLoaded is dispatched in `SheetComplete` below.
https://searchfox.org/mozilla-central/rev/b7e3ec2468d42fa59d86c03ec7afeb209813f1d4/layout/style/Loader.cpp#2489-2493
> void
> Loader::HandleLoadEvent(SheetLoadData* aEvent)
> {
> ...
>   if (!aEvent->mIsCancelled) {
>     // SheetComplete will call Release(), so give it a reference to do
>     // that with.
>     NS_ADDREF(aEvent);
>     SheetComplete(aEvent, NS_OK);
>   }
> 
>   if (mDocument) {
>     mDocument->UnblockOnload(true);
bz, can you take a look?
what's the expected flow around binding constructor and events?
  * is it expected that some event may be dispatched before binding gets constructed?
  * is it expected that correct execution depends on vsync? (on successful case constructor is called inside it, and on failure case it's not)
Flags: needinfo?(bzbarsky)
So we're basically racing execution of the constructor of the <browser> binding against the DOMFrameContentLoaded for ... which document?  The stacks above show DOMFrameContentLoaded being called via a callstack including XULDocument::DoneWalking().  Is that the document the <browser> in question is in, or the document inside the <browser> or something else?  And which one is the test looking for?

>  * is it expected that some event may be dispatched before binding gets constructed?

Generally speaking, yes, given that constructor execution is async.

> is it expected that correct execution depends on vsync? 

"Maybe".  XBL binding constructor timing is ... not terribly clearly guaranteed.
Flags: needinfo?(bzbarsky)
thank you :D

(In reply to Boris Zbarsky [:bz] (no decent commit message means r-) from comment #12)
> So we're basically racing execution of the constructor of the <browser>
> binding against the DOMFrameContentLoaded for ... which document?  The
> stacks above show DOMFrameContentLoaded being called via a callstack
> including XULDocument::DoneWalking().  Is that the document the <browser> in
> question is in, or the document inside the <browser> or something else?  And
> which one is the test looking for?

okay, I'll check the details about them.


> >  * is it expected that some event may be dispatched before binding gets constructed?
> 
> Generally speaking, yes, given that constructor execution is async.
> 
> > is it expected that correct execution depends on vsync? 
> 
> "Maybe".  XBL binding constructor timing is ... not terribly clearly
> guaranteed.

I see.
in that case some places may need to check if the XBL binding is already constructed
(and delay the execution of the remaining part until it gets constructed, maybe?)
Priority: -- → P2
here is the flow for both cases.

[successful case]
  * log "Entering test bound check_titlebar_focus_returnval_titlechanges_accepting"
  * gSubDialog.open
      | url=chrome://mochitests/content/browser/browser/components/preferences/in-content/tests/subdialog.xul
      |
      + SubDialog.prototype.open
      |   url=chrome://mochitests/content/browser/browser/components/preferences/in-content/tests/subdialog.xul
      |   name=dialogFrame-0
      |
      + SubDialog constructor called by gSubDialog.open
          | name=dialogFrame-1
          |
          + SubDialog.prototype.open after `await this._frameCreated`
              | name=dialogFrame-0
              | url=chrome://mochitests/content/browser/browser/components/preferences/in-content/tests/subdialog.xul
              | microtask checkpoint in `parentElement.appendChild(this._overlay)` in SubDialog constructor
              |
              + window.openDialog called by SubDialog.prototype.open
                  name=dialogFrame-0
                  url=chrome://mochitests/content/browser/browser/components/preferences/in-content/tests/subdialog.xul
  * browser constructor
      name=dialogFrame-1
  * browser constructor
      name=dialogFrame-0
  * log "waiting for subdialog DOMFrameContentLoaded"
  * XULDocument::DoneWalking begin
      documentURI=chrome://mochitests/content/browser/browser/components/preferences/in-content/tests/subdialog.xul
  * DOMFrameContentLoaded
      name=dialogFrame-0
  * XULDocument::DoneWalking end
      documentURI=chrome://mochitests/content/browser/browser/components/preferences/in-content/tests/subdialog.xul end
  * DOMFrameContentLoaded
      name=dialogFrame-1
  * log "waiting for subdialog load"

[failed case]
  * log "Entering test bound check_titlebar_focus_returnval_titlechanges_accepting"
  * gSubDialog.open
      | url=chrome://mochitests/content/browser/browser/components/preferences/in-content/tests/subdialog.xul
      |
      + SubDialog.prototype.open
      |   url=chrome://mochitests/content/browser/browser/components/preferences/in-content/tests/subdialog.xul
      |   name=dialogFrame-0
      |
      + SubDialog constructor called by gSubDialog.open
          | name=dialogFrame-1
          |
          + SubDialog.prototype.open after `await this._frameCreated`
              | name=dialogFrame-0
              | url=chrome://mochitests/content/browser/browser/components/preferences/in-content/tests/subdialog.xul
              | microtask checkpoint in `parentElement.appendChild(this._overlay)` in SubDialog constructor
              |
              + window.openDialog called by SubDialog.prototype.open
                  name=dialogFrame-0
                  url=chrome://mochitests/content/browser/browser/components/preferences/in-content/tests/subdialog.xul
  * log "waiting for subdialog DOMFrameContentLoaded"
  * XULDocument::DoneWalking begin
      documentURI=chrome://mochitests/content/browser/browser/components/preferences/in-content/tests/subdialog.xul
  * DOMFrameContentLoaded
      name=dialogFrame-0
      !!!! contentWindow=undefined
  * XULDocument::DoneWalking end
      documentURI=chrome://mochitests/content/browser/browser/components/preferences/in-content/tests/subdialog.xul
  * browser constructor
      name=dialogFrame-1
  * browser constructor
      name=dialogFrame-0
  * DOMFrameContentLoaded
     name=dialogFrame-1
  * log "waiting for subdialog load"


First, gSubDialog.init calls SubDialog constructor as preload:
https://searchfox.org/mozilla-central/rev/38bddf549db0f26d4d7575cf695958ff703a3ed7/browser/components/preferences/in-content/subdialogs.js#517-519
> var gSubDialog = {
> ...
>   init() {
> ...
>     this._preloadDialog = new SubDialog({template: this._dialogTemplate,
>                                          parentElement: this._dialogStack,
>                                          id: this._nextDialogID++});

and the SubDialog constructor clones template for dialog:
https://searchfox.org/mozilla-central/rev/38bddf549db0f26d4d7575cf695958ff703a3ed7/browser/components/preferences/in-content/subdialogs.js#20
> function SubDialog({template, parentElement, id}) {
> ...
>   this._overlay = template.cloneNode(true);

the template contains browser:
https://searchfox.org/mozilla-central/rev/38bddf549db0f26d4d7575cf695958ff703a3ed7/browser/components/preferences/in-content/preferences.xul#225-227
>   <vbox id="dialogTemplate" class="dialogOverlay" align="center" pack="center" topmost="true" hidden="true">
> ...
>       <browser class="dialogFrame"
>                autoscroll="false"
>                disablehistory="true"/>

Then, the testcase opens dialog,
here args.url is "chrome://mochitests/content/browser/browser/components/preferences/in-content/tests/subdialog.xul"
https://searchfox.org/mozilla-central/rev/38bddf549db0f26d4d7575cf695958ff703a3ed7/browser/components/preferences/in-content/tests/browser_subdialogs.js#20
> function open_subdialog_and_test_generic_start_state(browser, domcontentloadedFn, url = gDialogURL) {
> ...
>   return ContentTask.spawn(browser, {url, domcontentloadedFnStr}, async function(args) {
> ...
>     content.gSubDialog.open(args.url, null, rv);

gSubDialog.open opens the given URL into preloaded dialog,
the name of the preloaded dialog is "dialogFrame-0"
https://searchfox.org/mozilla-central/rev/38bddf549db0f26d4d7575cf695958ff703a3ed7/browser/components/preferences/in-content/subdialogs.js#528
> var gSubDialog = {
> ...
>   open(aURL, aFeatures = null, aParams = null, aClosingCallback = null) {
> ...
>     this._preloadDialog.open(aURL, aFeatures, aParams, aClosingCallback);

the the preloaded SubDialog instance opens the given URL into the already-cloned browser with name="dialogFrame-0".
https://searchfox.org/mozilla-central/rev/38bddf549db0f26d4d7575cf695958ff703a3ed7/browser/components/preferences/in-content/subdialogs.js#89
>   async open(aURL, aFeatures = null, aParams = null, aClosingCallback = null) {
> ...
>     let dialog = window.openDialog(aURL, `dialogFrame-${this._id}`, features, aParams);

and the preloaded SubDialog instance adds itself to DOMFrameContentLoaded event listener:
https://searchfox.org/mozilla-central/rev/38bddf549db0f26d4d7575cf695958ff703a3ed7/browser/components/preferences/in-content/subdialogs.js#86
>   async open(aURL, aFeatures = null, aParams = null, aClosingCallback = null) {
> ...
>     this._addDialogEventListeners();

https://searchfox.org/mozilla-central/rev/38bddf549db0f26d4d7575cf695958ff703a3ed7/browser/components/preferences/in-content/subdialogs.js#439
>   _addDialogEventListeners() {
> ...
>    window.addEventListener("DOMFrameContentLoaded", this, true);

and then, gSubDialog creates one more SubDialog instance for preload,
the name of the new preload dialog is "dialogFrame-1",
and it will also clones template.
https://searchfox.org/mozilla-central/rev/38bddf549db0f26d4d7575cf695958ff703a3ed7/browser/components/preferences/in-content/subdialogs.js#530-532
> var gSubDialog = {
> ...
>   open(aURL, aFeatures = null, aParams = null, aClosingCallback = null) {
> ...
>     this._preloadDialog = new SubDialog({template: this._dialogTemplate,
>                                          parentElement: this._dialogStack,
>                                          id: this._nextDialogID++});


Now there are 2 browser elements that is loading,
  * dialogFrame-0's one, for "chrome://mochitests/content/browser/browser/components/preferences/in-content/tests/subdialog.xul"
  * dialogFrame-1's one, that is preload (no specific URL, I suppose it will be about:blank)

Then, DOMFrameContentLoaded event is dispatched for both of them, to dialogFrame-0's SubDialog instance.
here, DOMFrameContentLoaded for dialogFrame-0 is called inside XULDocument::DoneWalking for itself (chrome://mochitests/content/browser/browser/components/preferences/in-content/tests/subdialog.xul)

on successful case, the browser constructor is already called at that point,
and contentWindow getter returns correct window.
on failure case, the browser constructor is not yet called at that point,
and contentWindow getter is not yet defined, and the value becomes undefined.

looks like the another preloaded dialog dialogFrame-1 is not so much related to the issue, but I cannot isolate it.


so, here's the answer.

> So we're basically racing execution of the constructor of the <browser>
> binding against the DOMFrameContentLoaded for ... which document?

browser constructor for the browser, cloned from template,
that is loading chrome://mochitests/content/browser/browser/components/preferences/in-content/tests/subdialog.xul
against DOMFrameContentLoaded for the document that is loading chrome://mochitests/content/browser/browser/components/preferences/in-content/tests/subdialog.xul
that should be inside that browser

> The stacks above show DOMFrameContentLoaded being called via a callstack
> including XULDocument::DoneWalking().  Is that the document the <browser> in
> question is in, or the document inside the <browser> or something else?

yes, XULDocument::DoneWalking is for chrome://mochitests/content/browser/browser/components/preferences/in-content/tests/subdialog.xul
so, I guess the issue is that SubDialog is using the browser before the clone finishes, maybe?
I'll check how everything was working before bug 1193394
here's the flow before bug 1193394

  * log "Entering test bound check_titlebar_focus_returnval_titlechanges_accepting"
  * gSubDialog.open
      | url=chrome://mochitests/content/browser/browser/components/preferences/in-content/tests/subdialog.xul
      |
      + SubDialog.prototype.open
      |   url=chrome://mochitests/content/browser/browser/components/preferences/in-content/tests/subdialog.xul
      |   name=dialogFrame-0
      |
      + SubDialog constructor
          name=dialogFrame-1
  * SubDialog.prototype.open after `await this._frameCreated`
      | name=dialogFrame-0
      | url=chrome://mochitests/content/browser/browser/components/preferences/in-content/tests/subdialog.xul
      |
      + window.openDialog
          name=dialogFrame-0
          url=chrome://mochitests/content/browser/browser/components/preferences/in-content/tests/subdialog.xul
  * log "waiting for subdialog DOMFrameContentLoaded"
  * browser constructor
      name=dialogFrame-1
  * browser constructor
      name=dialogFrame-0
  * DOMFrameContentLoaded
      name=dialogFrame-1
  * XULDocument::DoneWalking begin
      url=chrome://mochitests/content/browser/browser/components/preferences/in-content/tests/subdialog.xul
  * DOMFrameContentLoaded
      name=dialogFrame-0
  * XULDocument::DoneWalking end
      url=chrome://mochitests/content/browser/browser/components/preferences/in-content/tests/subdialog.xul
  * log "waiting for subdialog load"

and stack for browser constructor and DOMFrameContentLoaded

[browser constructor 1] = dialogFrame-1

0   XUL                                 0x000000010e01e748 DumpNativeBacktrace(JSContext*, unsigned int, JS::Value*) + 40
1   XUL                                 0x000000010dd6a575 js::InternalCallOrConstruct(JSContext*, JS::CallArgs const&, js::MaybeConstruct) + 661
2   XUL                                 0x000000010dd65613 Interpret(JSContext*, js::RunState&) + 34083
3   XUL                                 0x000000010dd5cf18 js::RunScript(JSContext*, js::RunState&) + 312
4   XUL                                 0x000000010dd6a6b5 js::InternalCallOrConstruct(JSContext*, JS::CallArgs const&, js::MaybeConstruct) + 981
5   XUL                                 0x000000010dd6a949 js::Call(JSContext*, JS::Handle<JS::Value>, JS::Handle<JS::Value>, js::AnyInvokeArgs const&, JS::MutableHandle<JS::Value>) + 41
6   XUL                                 0x000000010e098eae JS_CallFunctionValue(JSContext*, JS::Handle<JSObject*>, JS::Handle<JS::Value>, JS::HandleValueArray const&, JS::MutableHandle<JS::Value>) + 398
7   XUL                                 0x000000010c68b2cc nsXBLProtoImplAnonymousMethod::Execute(nsIContent*, JSAddonId*) + 780
8   XUL                                 0x000000010c67cf9c nsBindingManager::ProcessAttachedQueueInternal(unsigned int) + 156
9   XUL                                 0x000000010ca53d0d mozilla::PresShell::DoFlushPendingNotifications(mozilla::ChangesToFlush) + 1453
10  XUL                                 0x000000010ca29ec9 nsRefreshDriver::Tick(long long, mozilla::TimeStamp) + 2729
11  XUL                                 0x000000010ca29a58 nsRefreshDriver::Tick(long long, mozilla::TimeStamp) + 1592
12  XUL                                 0x000000010ca2c4c2 nsRefreshDriver::FinishedWaitingForTransaction() + 386
13  XUL                                 0x000000010b3bcf2b mozilla::layers::ClientLayerManager::DidComposite(unsigned long long, mozilla::TimeStamp const&, mozilla::TimeStamp const&) + 139
14  XUL                                 0x000000010b405790 mozilla::layers::CompositorBridgeChild::RecvDidComposite(unsigned long long const&, unsigned long long const&, mozilla::TimeStamp const&, mozilla::TimeStamp const&) + 304
15  XUL                                 0x000000010aed7efa mozilla::layers::PCompositorBridgeChild::OnMessageReceived(IPC::Message const&) + 698
16  XUL                                 0x000000010abffea1 mozilla::ipc::MessageChannel::DispatchAsyncMessage(IPC::Message const&) + 113
17  XUL                                 0x000000010abff035 mozilla::ipc::MessageChannel::DispatchMessage(IPC::Message&&) + 325
18  XUL                                 0x000000010abff94e mozilla::ipc::MessageChannel::MessageTask::Run() + 78
19  XUL                                 0x000000010a78de4a nsThread::ProcessNextEvent(bool, bool*) + 1658
20  XUL                                 0x000000010a796759 NS_ProcessPendingEvents(nsIThread*, unsigned int) + 73
21  XUL                                 0x000000010c7ce361 nsBaseAppShell::NativeEventCallback() + 113
22  XUL                                 0x000000010c824b48 nsAppShell::ProcessGeckoEvents(void*) + 248
23  CoreFoundation                      0x00007fff87758321 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 17
24  CoreFoundation                      0x00007fff87739197 __CFRunLoopDoSources0 + 423
25  CoreFoundation                      0x00007fff87738716 __CFRunLoopRun + 934
26  CoreFoundation                      0x00007fff87738114 CFRunLoopRunSpecific + 420
27  HIToolbox                           0x00007fff86c98ebc RunCurrentEventLoopInMode + 240
28  HIToolbox                           0x00007fff86c98cf1 ReceiveNextEventCommon + 432
29  HIToolbox                           0x00007fff86c98b26 _BlockUntilNextEventMatchingListInModeWithFilter + 71
30  AppKit                              0x00007fff8522fa54 _DPSNextEvent + 1120
31  AppKit                              0x00007fff859ab7ee -[NSApplication(NSEvent) _nextEventMatchingEventMask:untilDate:inMode:dequeue:] + 2796
32  XUL                                 0x000000010c8241c6 -[GeckoNSApplication nextEventMatchingMask:untilDate:inMode:dequeue:] + 86
33  AppKit                              0x00007fff852243db -[NSApplication run] + 926
34  XUL                                 0x000000010c825077 nsAppShell::Run() + 247
35  XUL                                 0x000000010db94a74 nsAppStartup::Run() + 68
36  XUL                                 0x000000010dc4071a XREMain::XRE_mainRun() + 3578
37  XUL                                 0x000000010dc40f69 XREMain::XRE_main(int, char**, mozilla::BootstrapConfig const&) + 1065
38  XUL                                 0x000000010dc414e3 XRE_main(int, char**, mozilla::BootstrapConfig const&) + 227
39  firefox                             0x0000000108a31026 main + 822
40  firefox                             0x0000000108a30cc4 start + 52
41  ???                                 0x0000000000000005 0x0 + 5

[browser constructor 1] = dialogFrame-0

0   XUL                                 0x000000010e01e748 DumpNativeBacktrace(JSContext*, unsigned int, JS::Value*) + 40
1   XUL                                 0x000000010dd6a575 js::InternalCallOrConstruct(JSContext*, JS::CallArgs const&, js::MaybeConstruct) + 661
2   XUL                                 0x000000010dd65613 Interpret(JSContext*, js::RunState&) + 34083
3   XUL                                 0x000000010dd5cf18 js::RunScript(JSContext*, js::RunState&) + 312
4   XUL                                 0x000000010dd6a6b5 js::InternalCallOrConstruct(JSContext*, JS::CallArgs const&, js::MaybeConstruct) + 981
5   XUL                                 0x000000010dd6a949 js::Call(JSContext*, JS::Handle<JS::Value>, JS::Handle<JS::Value>, js::AnyInvokeArgs const&, JS::MutableHandle<JS::Value>) + 41
6   XUL                                 0x000000010e098eae JS_CallFunctionValue(JSContext*, JS::Handle<JSObject*>, JS::Handle<JS::Value>, JS::HandleValueArray const&, JS::MutableHandle<JS::Value>) + 398
7   XUL                                 0x000000010c68b2cc nsXBLProtoImplAnonymousMethod::Execute(nsIContent*, JSAddonId*) + 780
8   XUL                                 0x000000010c67cf9c nsBindingManager::ProcessAttachedQueueInternal(unsigned int) + 156
9   XUL                                 0x000000010ca53d0d mozilla::PresShell::DoFlushPendingNotifications(mozilla::ChangesToFlush) + 1453
10  XUL                                 0x000000010ca29ec9 nsRefreshDriver::Tick(long long, mozilla::TimeStamp) + 2729
11  XUL                                 0x000000010ca29a58 nsRefreshDriver::Tick(long long, mozilla::TimeStamp) + 1592
12  XUL                                 0x000000010ca2c4c2 nsRefreshDriver::FinishedWaitingForTransaction() + 386
13  XUL                                 0x000000010b3bcf2b mozilla::layers::ClientLayerManager::DidComposite(unsigned long long, mozilla::TimeStamp const&, mozilla::TimeStamp const&) + 139
14  XUL                                 0x000000010b405790 mozilla::layers::CompositorBridgeChild::RecvDidComposite(unsigned long long const&, unsigned long long const&, mozilla::TimeStamp const&, mozilla::TimeStamp const&) + 304
15  XUL                                 0x000000010aed7efa mozilla::layers::PCompositorBridgeChild::OnMessageReceived(IPC::Message const&) + 698
16  XUL                                 0x000000010abffea1 mozilla::ipc::MessageChannel::DispatchAsyncMessage(IPC::Message const&) + 113
17  XUL                                 0x000000010abff035 mozilla::ipc::MessageChannel::DispatchMessage(IPC::Message&&) + 325
18  XUL                                 0x000000010abff94e mozilla::ipc::MessageChannel::MessageTask::Run() + 78
19  XUL                                 0x000000010a78de4a nsThread::ProcessNextEvent(bool, bool*) + 1658
20  XUL                                 0x000000010a796759 NS_ProcessPendingEvents(nsIThread*, unsigned int) + 73
21  XUL                                 0x000000010c7ce361 nsBaseAppShell::NativeEventCallback() + 113
22  XUL                                 0x000000010c824b48 nsAppShell::ProcessGeckoEvents(void*) + 248
23  CoreFoundation                      0x00007fff87758321 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 17
24  CoreFoundation                      0x00007fff87739197 __CFRunLoopDoSources0 + 423
25  CoreFoundation                      0x00007fff87738716 __CFRunLoopRun + 934
26  CoreFoundation                      0x00007fff87738114 CFRunLoopRunSpecific + 420
27  HIToolbox                           0x00007fff86c98ebc RunCurrentEventLoopInMode + 240
28  HIToolbox                           0x00007fff86c98cf1 ReceiveNextEventCommon + 432
29  HIToolbox                           0x00007fff86c98b26 _BlockUntilNextEventMatchingListInModeWithFilter + 71
30  AppKit                              0x00007fff8522fa54 _DPSNextEvent + 1120
31  AppKit                              0x00007fff859ab7ee -[NSApplication(NSEvent) _nextEventMatchingEventMask:untilDate:inMode:dequeue:] + 2796
32  XUL                                 0x000000010c8241c6 -[GeckoNSApplication nextEventMatchingMask:untilDate:inMode:dequeue:] + 86
33  AppKit                              0x00007fff852243db -[NSApplication run] + 926
34  XUL                                 0x000000010c825077 nsAppShell::Run() + 247
35  XUL                                 0x000000010db94a74 nsAppStartup::Run() + 68
36  XUL                                 0x000000010dc4071a XREMain::XRE_mainRun() + 3578
37  XUL                                 0x000000010dc40f69 XREMain::XRE_main(int, char**, mozilla::BootstrapConfig const&) + 1065
38  XUL                                 0x000000010dc414e3 XRE_main(int, char**, mozilla::BootstrapConfig const&) + 227
39  firefox                             0x0000000108a31026 main + 822
40  firefox                             0x0000000108a30cc4 start + 52
41  ???                                 0x0000000000000005 0x0 + 5

[DOMFrameContentLoaded 1] = dialogFrame-1

0   XUL                                 0x000000010e01e748 DumpNativeBacktrace(JSContext*, unsigned int, JS::Value*) + 40
1   XUL                                 0x000000010dd6a575 js::InternalCallOrConstruct(JSContext*, JS::CallArgs const&, js::MaybeConstruct) + 661
2   XUL                                 0x000000010dd65613 Interpret(JSContext*, js::RunState&) + 34083
3   XUL                                 0x000000010dd5cf18 js::RunScript(JSContext*, js::RunState&) + 312
4   XUL                                 0x000000010dd6a6b5 js::InternalCallOrConstruct(JSContext*, JS::CallArgs const&, js::MaybeConstruct) + 981
5   XUL                                 0x000000010dd65613 Interpret(JSContext*, js::RunState&) + 34083
6   XUL                                 0x000000010dd5cf18 js::RunScript(JSContext*, js::RunState&) + 312
7   XUL                                 0x000000010dd6a6b5 js::InternalCallOrConstruct(JSContext*, JS::CallArgs const&, js::MaybeConstruct) + 981
8   XUL                                 0x000000010dd6a949 js::Call(JSContext*, JS::Handle<JS::Value>, JS::Handle<JS::Value>, js::AnyInvokeArgs const&, JS::MutableHandle<JS::Value>) + 41
9   XUL                                 0x000000010e09984a JS::Call(JSContext*, JS::Handle<JS::Value>, JS::Handle<JS::Value>, JS::HandleValueArray const&, JS::MutableHandle<JS::Value>) + 298
10  XUL                                 0x000000010bca9dd3 mozilla::dom::EventListener::HandleEvent(JSContext*, JS::Handle<JS::Value>, mozilla::dom::Event&, mozilla::ErrorResult&) + 691
11  XUL                                 0x000000010bfd50c0 mozilla::EventListenerManager::HandleEventSubType(mozilla::EventListenerManager::Listener*, nsIDOMEvent*, mozilla::dom::EventTarget*) + 352
12  XUL                                 0x000000010bfd5bf3 mozilla::EventListenerManager::HandleEventInternal(nsPresContext*, mozilla::WidgetEvent*, nsIDOMEvent**, mozilla::dom::EventTarget*, nsEventStatus*) + 2643
13  XUL                                 0x000000010bfcefac mozilla::EventTargetChainItem::HandleEventTargetChain(nsTArray<mozilla::EventTargetChainItem>&, mozilla::EventChainPostVisitor&, mozilla::EventDispatchingCallback*, mozilla::ELMCreationDetector&) + 268
14  XUL                                 0x000000010bfd0169 mozilla::EventDispatcher::Dispatch(nsISupports*, nsPresContext*, mozilla::WidgetEvent*, nsIDOMEvent*, nsEventStatus*, mozilla::EventDispatchingCallback*, nsTArray<mozilla::dom::EventTarget*>*) + 2665
15  XUL                                 0x000000010b6984b8 nsDocument::DispatchContentLoadedEvents() + 568
16  XUL                                 0x000000010b6b9627 mozilla::detail::RunnableMethodImpl<nsDocument*, void (nsDocument::*)(), true, (mozilla::RunnableKind)0>::Run() + 39
17  XUL                                 0x000000010a78de4a nsThread::ProcessNextEvent(bool, bool*) + 1658
18  XUL                                 0x000000010a796759 NS_ProcessPendingEvents(nsIThread*, unsigned int) + 73
19  XUL                                 0x000000010c7ce361 nsBaseAppShell::NativeEventCallback() + 113
20  XUL                                 0x000000010c824b48 nsAppShell::ProcessGeckoEvents(void*) + 248
21  CoreFoundation                      0x00007fff87758321 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 17
22  CoreFoundation                      0x00007fff87739197 __CFRunLoopDoSources0 + 423
23  CoreFoundation                      0x00007fff87738716 __CFRunLoopRun + 934
24  CoreFoundation                      0x00007fff87738114 CFRunLoopRunSpecific + 420
25  HIToolbox                           0x00007fff86c98ebc RunCurrentEventLoopInMode + 240
26  HIToolbox                           0x00007fff86c98cf1 ReceiveNextEventCommon + 432
27  HIToolbox                           0x00007fff86c98b26 _BlockUntilNextEventMatchingListInModeWithFilter + 71
28  AppKit                              0x00007fff8522fa54 _DPSNextEvent + 1120
29  AppKit                              0x00007fff859ab7ee -[NSApplication(NSEvent) _nextEventMatchingEventMask:untilDate:inMode:dequeue:] + 2796
30  XUL                                 0x000000010c8241c6 -[GeckoNSApplication nextEventMatchingMask:untilDate:inMode:dequeue:] + 86
31  AppKit                              0x00007fff852243db -[NSApplication run] + 926
32  XUL                                 0x000000010c825077 nsAppShell::Run() + 247
33  XUL                                 0x000000010db94a74 nsAppStartup::Run() + 68
34  XUL                                 0x000000010dc4071a XREMain::XRE_mainRun() + 3578
35  XUL                                 0x000000010dc40f69 XREMain::XRE_main(int, char**, mozilla::BootstrapConfig const&) + 1065
36  XUL                                 0x000000010dc414e3 XRE_main(int, char**, mozilla::BootstrapConfig const&) + 227
37  firefox                             0x0000000108a31026 main + 822
38  firefox                             0x0000000108a30cc4 start + 52
39  ???                                 0x0000000000000005 0x0 + 5

[DOMFrameContentLoaded 1] = dialogFrame-0

0   XUL                                 0x000000010e01e748 DumpNativeBacktrace(JSContext*, unsigned int, JS::Value*) + 40
1   XUL                                 0x000000010dd6a575 js::InternalCallOrConstruct(JSContext*, JS::CallArgs const&, js::MaybeConstruct) + 661
2   XUL                                 0x000000010dd65613 Interpret(JSContext*, js::RunState&) + 34083
3   XUL                                 0x000000010dd5cf18 js::RunScript(JSContext*, js::RunState&) + 312
4   XUL                                 0x000000010dd6a6b5 js::InternalCallOrConstruct(JSContext*, JS::CallArgs const&, js::MaybeConstruct) + 981
5   XUL                                 0x000000010dd65613 Interpret(JSContext*, js::RunState&) + 34083
6   XUL                                 0x000000010dd5cf18 js::RunScript(JSContext*, js::RunState&) + 312
7   XUL                                 0x000000010dd6a6b5 js::InternalCallOrConstruct(JSContext*, JS::CallArgs const&, js::MaybeConstruct) + 981
8   XUL                                 0x000000010dd6a949 js::Call(JSContext*, JS::Handle<JS::Value>, JS::Handle<JS::Value>, js::AnyInvokeArgs const&, JS::MutableHandle<JS::Value>) + 41
9   XUL                                 0x000000010e09984a JS::Call(JSContext*, JS::Handle<JS::Value>, JS::Handle<JS::Value>, JS::HandleValueArray const&, JS::MutableHandle<JS::Value>) + 298
10  XUL                                 0x000000010bca9dd3 mozilla::dom::EventListener::HandleEvent(JSContext*, JS::Handle<JS::Value>, mozilla::dom::Event&, mozilla::ErrorResult&) + 691
11  XUL                                 0x000000010bfd50c0 mozilla::EventListenerManager::HandleEventSubType(mozilla::EventListenerManager::Listener*, nsIDOMEvent*, mozilla::dom::EventTarget*) + 352
12  XUL                                 0x000000010bfd5bf3 mozilla::EventListenerManager::HandleEventInternal(nsPresContext*, mozilla::WidgetEvent*, nsIDOMEvent**, mozilla::dom::EventTarget*, nsEventStatus*) + 2643
13  XUL                                 0x000000010bfcefac mozilla::EventTargetChainItem::HandleEventTargetChain(nsTArray<mozilla::EventTargetChainItem>&, mozilla::EventChainPostVisitor&, mozilla::EventDispatchingCallback*, mozilla::ELMCreationDetector&) + 268
14  XUL                                 0x000000010bfd0169 mozilla::EventDispatcher::Dispatch(nsISupports*, nsPresContext*, mozilla::WidgetEvent*, nsIDOMEvent*, nsEventStatus*, mozilla::EventDispatchingCallback*, nsTArray<mozilla::dom::EventTarget*>*) + 2665
15  XUL                                 0x000000010b6984b8 nsDocument::DispatchContentLoadedEvents() + 568
16  XUL                                 0x000000010c6f2780 mozilla::dom::XULDocument::DoneWalking() + 1392
17  XUL                                 0x000000010c6f2b46 non-virtual thunk to mozilla::dom::XULDocument::StyleSheetLoaded(mozilla::StyleSheet*, bool, nsresult) + 38
18  XUL                                 0x000000010c923df9 mozilla::css::Loader::SheetComplete(mozilla::css::SheetLoadData*, nsresult) + 345
19  XUL                                 0x000000010c920b1f mozilla::css::SheetLoadData::Run() + 111
20  XUL                                 0x000000010a78de4a nsThread::ProcessNextEvent(bool, bool*) + 1658
21  XUL                                 0x000000010a796759 NS_ProcessPendingEvents(nsIThread*, unsigned int) + 73
22  XUL                                 0x000000010c7ce361 nsBaseAppShell::NativeEventCallback() + 113
23  XUL                                 0x000000010c824b48 nsAppShell::ProcessGeckoEvents(void*) + 248
24  CoreFoundation                      0x00007fff87758321 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 17
25  CoreFoundation                      0x00007fff87739197 __CFRunLoopDoSources0 + 423
26  CoreFoundation                      0x00007fff87738716 __CFRunLoopRun + 934
27  CoreFoundation                      0x00007fff87738114 CFRunLoopRunSpecific + 420
28  HIToolbox                           0x00007fff86c98ebc RunCurrentEventLoopInMode + 240
29  HIToolbox                           0x00007fff86c98cf1 ReceiveNextEventCommon + 432
30  HIToolbox                           0x00007fff86c98b26 _BlockUntilNextEventMatchingListInModeWithFilter + 71
31  AppKit                              0x00007fff8522fa54 _DPSNextEvent + 1120
32  AppKit                              0x00007fff859ab7ee -[NSApplication(NSEvent) _nextEventMatchingEventMask:untilDate:inMode:dequeue:] + 2796
33  XUL                                 0x000000010c8241c6 -[GeckoNSApplication nextEventMatchingMask:untilDate:inMode:dequeue:] + 86
34  AppKit                              0x00007fff852243db -[NSApplication run] + 926
35  XUL                                 0x000000010c825077 nsAppShell::Run() + 247
36  XUL                                 0x000000010db94a74 nsAppStartup::Run() + 68
37  XUL                                 0x000000010dc4071a XREMain::XRE_mainRun() + 3578
38  XUL                                 0x000000010dc40f69 XREMain::XRE_main(int, char**, mozilla::BootstrapConfig const&) + 1065
39  XUL                                 0x000000010dc414e3 XRE_main(int, char**, mozilla::BootstrapConfig const&) + 227
40  firefox                             0x0000000108a31026 main + 822
41  firefox                             0x0000000108a30cc4 start + 52
42  ???                                 0x0000000000000005 0x0 + 5


So, browser constructor was called in different timing, than successful case after bug 1193394.

and also the order of DOMFrameContentLoaded event was different.
DOMFrameContentLoaded for dialogFrame-1 was called before one for dialogFrame-0.
anyway, I guess SubDialog should wait for binding, at the same time as waiting for `await this._frameCreated` that is load event.
here are possible solutions:
  1. add a new event that is dispatched after calling XBL constructor, and wait for it in SubDialog
  2. poll binding's state (maybe by checking property) in SubDialog

1 would be straightforward way, but I'm concerning about the amount of events dispatched.
2 will also work but is not nice :/
Here's a prototype that dispatches "BindingCreated" event to the element with binding, after binding's constructor is called,
and SubDialog waits both for "load" and "BindingCreated" events for the browser.

the code for creating/dispatching event is copied from DOMFrameContentLoaded's case.
https://searchfox.org/mozilla-central/rev/38bddf549db0f26d4d7575cf695958ff703a3ed7/dom/base/nsDocument.cpp#5481-5517

can I have some feedback for this approach?
especially, is it fine if such event is dispatched for all bindings?
Attachment #8946020 - Flags: feedback?(bzbarsky)
Comment on attachment 8946020 [details] [diff] [review]
Dispatch BindingCreated event after calling XBL constructors, and wait for it in subdialog.js.

I would really rather not fire this event for all bindings...

Fundamentally, is the issue that we're doing a load in a display:none iframe toggled to be visible (or just inserting the iframe in the DOM but frame construction is lazy), then DOMContentLoaded fires whenever it does (which may be before the frame construction happens), then frame construction happens off a refresh tick and runs the XBL bits?

If that's what's going on, we may be able to work around the problem by forcing frame construction at the point where we want the binding to be attached.  So for example, if you do:


  this._frameCreated = new Promise(resolve => {
    this._frame.addEventListener("load", 
      function() {
        this._frame.getBoundingClientRect();
        resolve();
      },
      {once: true});
  });

does that help?
Attachment #8946020 - Flags: feedback?(bzbarsky) → feedback-
thank you for your feedback :)

(In reply to Boris Zbarsky [:bz] (no decent commit message means r-) from comment #21)
> Fundamentally, is the issue that we're doing a load in a display:none iframe
> toggled to be visible (or just inserting the iframe in the DOM but frame
> construction is lazy), then DOMContentLoaded fires whenever it does (which
> may be before the frame construction happens), then frame construction
> happens off a refresh tick and runs the XBL bits?

yeah, that's my understanding.
not sure about the details of frame construction order tho, DOMContentLoaded is fired before XBL constructor gets called.

> If that's what's going on, we may be able to work around the problem by
> forcing frame construction at the point where we want the binding to be
> attached.  So for example, if you do:
> 
> 
>   this._frameCreated = new Promise(resolve => {
>     this._frame.addEventListener("load", 
>       function() {
>         this._frame.getBoundingClientRect();
>         resolve();
>       },
>       {once: true});
>   });
> 
> does that help?

Unfortunately it doesn't construct XBL.
this._frame.contentWindow is still undefined and the rect is (0,0,0,0)
> Unfortunately it doesn't construct XBL.

Hmm.  Why not?

> and the rect is (0,0,0,0)

That sounds like it didn't even create the frame.  Again, why not?
calling getBoundingClientRect() inside _onContentLoaded (that is DOMFrameContentLoaded) constructs XBL and solves the issue.
I'll check what the difference is.
Anyway, this is the patch that fixed the issue.
I'll ask review after checking some more details and make sure why this is the right timing to call getBoundingClientRect.
Attachment #8946020 - Attachment is obsolete: true
dialogStack is "display: none" when browser binding is not yet constructed in "load" event,
and calling getBoundingClientRect doesn't construct frame there.

dialogStack is "display: -moz-stack" when browser binding is already constructed in "load" event.
apparently, I was looking at preloadDialog's load event, that is created in gSubDialog.init
https://searchfox.org/mozilla-central/rev/e06af9c36a73a27864302cd2f829e6200dee8541/browser/components/preferences/in-content/subdialogs.js#517-519

then for preloadDialog, _frameCreated promise is wrong, since dialogStack isn't displayed and frame is not created when "load" happens.
because dialogStack is displayed only in gSubDialog.open.
maybe I'm misunderstanding what "this._frameCreated" promise is for...?
if that's not something related to frame construction (and binding construction),
the patch above would be the right workaround.
then we could land it and look into the other details later (so that we can fix bug 1193394)
Considering there are other event handlers added, it should be better checking and constructing in SubDialog.prototype.open, just after `await this._frameCreated`

I'll ask review after try run for both before/after bug 1193394
Attachment #8948197 - Attachment is obsolete: true
Comment on attachment 8948201 [details] [diff] [review]
Forcibly construct the frame for browser to load browser binding in preferences subdialog.

Apparently the resolved `this._frameCreated` doesn't mean that the frame (I'm not sure if those 2 "frame" word means the same thing tho) and binding gets constructed,
because the promise is resolved in "load" event, that is dispatched while the enclosing dialog stack is hidden, for preload dialog.

So, we should make sure the frame and binding are already constructed before continuing the remaining part of `SubDialog.prototype.open`, after awaiting on the `this._frameCreated` promise.

Added the code that checks the existence of browser binding getter, and if it doesn't exist, it calls `getBoundingClientRect()` to forcibly construct frame and binding,
so that all event handlers are added after the binding gets created, including DOMFrameContentLoaded.

then, to make `getBoundingClientRect()` effective inside `SubDialog.prototype.open`,
I moved `this._dialogStack.hidden = false;` before calling `SubDialog` constructor,
otherwise the dialog stack is still hidden for the first time the dialog is opened, and the frame is not constructed even if we call `getBoundingClientRect()`.
Attachment #8948201 - Flags: review?(bzbarsky)
Comment on attachment 8948201 [details] [diff] [review]
Forcibly construct the frame for browser to load browser binding in preferences subdialog.

r=me, but please file a followup to remove this hack once we stop using XBL for <browser>.  Check with :bgrins what bug(s) that followup should depend on.
Attachment #8948201 - Flags: review?(bzbarsky) → review+
See Also: → 1437247
Pushed by arai_a@mac.com:
https://hg.mozilla.org/integration/mozilla-inbound/rev/deea96928bdd
Forcibly construct the frame for browser to construct browser binding in preferences subdialog. r=bz
https://hg.mozilla.org/integration/mozilla-inbound/rev/deea96928bddafcc4ca2924368b70cd1cbdc6c3c
Bug 1431960 - Forcibly construct the frame for browser to construct browser binding in preferences subdialog. r=bz
https://hg.mozilla.org/mozilla-central/rev/deea96928bdd
Status: ASSIGNED → RESOLVED
Closed: 2 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla60
You need to log in before you can comment on or make changes to this bug.