[JavaScript Error: "TypeError: doc is null" {file: "resource:///actors/ContextMenuChild.sys.mjs" line: 559}]
Categories
(Firefox :: Menus, defect, P3)
Tracking
()
People
(Reporter: robwu, Assigned: robwu, NeedInfo)
References
(Blocks 2 open bugs)
Details
(Keywords: leave-open, Whiteboard: [addons-jira])
Attachments
(1 file)
| Assignee | ||
Comment 1•8 years ago
|
||
Comment 2•8 years ago
|
||
Updated•8 years ago
|
| Assignee | ||
Comment 3•8 years ago
|
||
Comment 4•7 years ago
|
||
As I just mentioned in Bug 1484789 comment 29, this issue seems to be happening in tests that are using (through BrowserTestUtils.synthesizeMouse*) DOMWindowUtils.sendMouseEvent to trigger the context menu mouse event in a newly created remote browser (but I doubt that the issue is specific to the context menu event).
As described in Bug 1519808 comment 0, two calls to DOMWindowUtils.sendMouseEvent with the same parameters (in particular the left and top that should point to the expected DOM element) seems to have different outcomes from time to time (and it seems to be some kind of race, because an arbitrary delay between the remote browser creation and the DOMWindowUtils.sendMouseEvent call seems to be able to reduce the issue).
Comment 5•4 years ago
|
||
This is not just intermittent, can be triggered with 100% reliability if you edit devtools/client/jsonview/test/browser.ini to remove
skip-if =
(os == 'linux' && !swgl) # bug 1720898
And then browser_jsonview_save_json.js fails in treeherder in linux (locally it passes for me).
Example: https://treeherder.mozilla.org/jobs?revision=f7c85f8174029853d35bd00b8165e8892286d802&repo=try
Comment 6•4 years ago
|
||
The test failure in bug 1682681 is due to synthesizemouse on the center of an element, and the center of the element is not visible. Restructuring the test html file to avoid that issue.
Updated•3 years ago
|
| Assignee | ||
Comment 7•3 years ago
|
||
Observed failure in bug 1775563, e.g. https://treeherder.mozilla.org/logviewer?job_id=419063159&repo=try&lineNumber=6029
Relevant log file pasted at https://bugzilla.mozilla.org/show_bug.cgi?id=1775563#c41
(also, updating title to adjust for the renamed file.)
| Assignee | ||
Comment 8•2 years ago
|
||
After fixing an intermittent failure, the bug got re-opened due to a "new" intermittent failure: https://bugzilla.mozilla.org/show_bug.cgi?id=1847216#c47
That failure is caused by this bug.
Since the problem has been ongoing for six years and stays under the radar because the blame goes to the test timeouts, I'll add some logging to make it easier to debug this issue next time it occurs.
Updated•2 years ago
|
| Assignee | ||
Comment 9•2 years ago
|
||
Comment 10•2 years ago
|
||
Comment 11•2 years ago
|
||
| bugherder | ||
| Assignee | ||
Comment 12•2 years ago
|
||
(In reply to Rob Wu [:robwu] from comment #1)
This error message suggests that aEvent.composedTarget.ownerDocument is null.
With the extra logging, I've confirmed that this is the case. I checked a handful of logs across different bugs, and all logs look like this:
doc is unexpectedly null (bug 1478596), composedTarget=[object HTMLDocument]
Alternative: target=[object HTMLDocument] and its doc=null
Alternative: originalTarget=[object HTMLDocument] and its doc=null
Alternative: explicitOriginalTarget=[object HTMLDocument] and its doc=null
JavaScript error: resource:///actors/ContextMenuChild.sys.mjs, line 559: TypeError: doc is null
Interestingly, all different target fields point to the HTML doc as being the target.
Would the error go away if you add a fall back to aEvent.target.ownerDocument:
let doc = aEvent.composedTarget.ownerDocument || aEvent.target.ownerDocument;
The error would not go away, because ownerDocument of a document is null, as the logs show.
(In reply to Olli Pettay [:smaug][bugs@pettay.fi] from comment #2)
I guess that it possible, if the event is targeted on, hmm, scrollbar or
something, which is native anonymous.
I think that this theory is increasingly likely. Knowing that this happens doesn't fix the bug though.
To find a potential solution, we could log the x,y offsets of the click, the dimensions of the document, and whether there are other viable alternatives such as document.elementsFromPoint(x,y).
Comment 13•2 years ago
|
||
Would this work?
let target = aEvent.composedTarget;
let doc = target.nodeType == Node.DOCUMENT_NODE ? target : target.ownerDocument;
| Assignee | ||
Comment 14•2 years ago
|
||
(In reply to Oriol Brufau [:Oriol] from comment #13)
Would this work?
let target = aEvent.composedTarget; let doc = target.nodeType == Node.DOCUMENT_NODE ? target : target.ownerDocument;
This would get rid of the error, but I'm not sure if it would result in meaningful behavior. The intent of tests is often to open a context menu on a specific target (e.g. link in page). Triggering the context menu on the document could result in confusing behavior.
Comment 15•1 year ago
|
||
The leave-open keyword is there and there is no activity for 6 months.
:robwu, maybe it's time to close this bug?
For more information, please visit BugBot documentation.
Comment 16•1 year ago
|
||
I can reproduce this failure consistently on Linux opt builds with the patch from Bug 543435 on browser_pocket_panel.js (see Bug 1781272), only in headless mode. But it is sensitive to small changes in timing.
Comment 17•1 year ago
|
||
Updated•1 year ago
|
Comment 18•1 year ago
|
||
I resolved the issue with that test, the pocket panel wasn't readily loaded when the click was synthesized.
Comment 19•12 days ago
•
|
||
The fix from Florian in bug 1970802 (to BrowserTestUtils to wait for a reflow in the parent process which should cause updated layout info for the viewport to be posted to the child) I think will get rid of most of the remainder of the failures here? Though not sure how best to check that that is the case.
Description
•