Open Bug 1832494 Opened 2 years ago Updated 2 years ago

JavaScript error: resource://gre/actors/BrowserElementChild.sys.mjs, line 19: TypeError: can't access property "windowUtils", this.contentWindow is null

Categories

(Toolkit :: Content Prompts, defect)

defect

Tracking

()

People

(Reporter: whimboo, Unassigned, NeedInfo)

References

Details

Seen in the following Marionette unit test:
https://treeherder.mozilla.org/logviewer?job_id=415292921&repo=autoland&lineNumber=36907

[task 2023-05-11T01:58:01.116Z] 01:58:01     INFO -  1683770281113	Marionette	DEBUG	8 -> [0,38,"WebDriver:ExecuteScript",{"script":"const [ modalType, browsingContextId, delay ] = arguments;\n\n                const modalTypes = {\n                  1: Service ... odalTypes[modalType],\n                    \"title\",\n                    \"text\"\n                  );\n                }, delay);","args":[2,20,0],"newSandbox":true,"sandbox":"default","line":54,"filename":"Z:\\task_168376051528613\\build\\tests\\marionette\\tests\\testing\\marionette\\harness\\marionette_harness\\tests\\unit\\test_modal_dialogs.py"}]
[task 2023-05-11T01:58:01.117Z] 01:58:01     INFO -  1683770281116	RemoteAgent	TRACE	WebDriverProcessData actor created for PID 1612
[task 2023-05-11T01:58:01.117Z] 01:58:01     INFO -  1683770281117	Marionette	TRACE	[1] MarionetteCommands actor created for window id 2
[task 2023-05-11T01:58:01.163Z] 01:58:01     INFO -  JavaScript error: resource://gre/actors/BrowserElementChild.sys.mjs, line 19: TypeError: can't access property "windowUtils", this.contentWindow is null
[task 2023-05-11T01:58:01.211Z] 01:58:01     INFO -  1683770281219	Marionette	TRACE	[20] MarionetteCommands actor destroyed for window id 45
[task 2023-05-11T01:58:01.242Z] 01:58:01     INFO -  1683770281246	Marionette	TRACE	Received event DOMModalDialogClosed
[task 2023-05-11T01:58:01.273Z] 01:58:01     INFO -  1683770281279	Marionette	DEBUG	8 <- [1,38,null,{"value":null}]

Related source:

https://searchfox.org/mozilla-central/rev/1f0f0e29a7bcb6d6dc82fe628861bccc2066a98e/toolkit/actors/BrowserElementChild.sys.mjs#19

So it happens when entering EnterModalState.

Blocks: 1832473
Blocks: 1816538

We have 17 failures over the last week on bug 1816538 which seems to be related to this error. Probably the prompt isn't correctly opened?

Dave, could someone please have a look which side-effect this failure can have? Thanks.

Flags: needinfo?(dtownsend)

this.contentWindow being null would normally happen if the window has already been closed before receiving the message. Does the test quickly close a modal window after opening it? It may be doing so too quickly. I don't think there is any bad side effect to this error, though it may suggest that the test isn't correctly verifying the modal state since it isn't set before the window is closed.

Flags: needinfo?(dtownsend)

The specific test only opens a prompt via script evaluation within the page. Then it awaits until the dialog appears like:

https://firefoxci.taskcluster-artifacts.net/ddcudTA1QtK6zURb1NQetg/0/public/logs/live_backing.log

[task 2023-05-17T10:30:54.270Z] 10:30:54     INFO -  1684319454269	Marionette	DEBUG	8 -> [0,38,"WebDriver:ExecuteScript",{"script":"const [ modalType, browsingContextId, delay ] = arguments;\n\n                const modalTypes = {\n                  1: Service ... odalTypes[modalType],\n                    \"title\",\n                    \"text\"\n                  );\n                }, delay);","args":[2,20,0],"newSandbox":true,"sandbox":"default","line":54,"filename":"Z:\\task_168431569922814\\build\\tests\\marionette\\tests\\testing\\marionette\\harness\\marionette_harness\\tests\\unit\\test_modal_dialogs.py"}]
[task 2023-05-17T10:30:54.272Z] 10:30:54     INFO -  1684319454272	RemoteAgent	TRACE	WebDriverProcessData actor created for PID 6316
[task 2023-05-17T10:30:54.272Z] 10:30:54     INFO -  1684319454272	Marionette	TRACE	[1] MarionetteCommands actor created for window id 2
[task 2023-05-17T10:30:54.341Z] 10:30:54     INFO -  1684319454341	Marionette	DEBUG	8 <- [1,38,null,{"value":null}]
[task 2023-05-17T10:30:54.372Z] 10:30:54     INFO -  1684319454380	Marionette	DEBUG	8 -> [0,39,"Marionette:SetContext",{"value":"content"}]
[task 2023-05-17T10:30:54.384Z] 10:30:54     INFO -  1684319454384	Marionette	DEBUG	8 <- [1,39,null,{"value":null}]
[task 2023-05-17T10:30:54.391Z] 10:30:54     INFO -  1684319454391	Marionette	DEBUG	8 -> [0,40,"WebDriver:GetAlertText",{}]
[task 2023-05-17T10:30:54.392Z] 10:30:54     INFO -  1684319454391	Marionette	DEBUG	8 <- [1,40,{"error":"no such alert","message":"","stacktrace":"RemoteError@chrome://remote/content/shared/RemoteError.sys.mjs:8:8\nWebDriverError@chrome://remote/content/shared/webdriver/Er ... 1569922814\\build\\tests\\marionette\\tests\\testing\\marionette\\harness\\marionette_harness\\tests\\unit\\test_modal_dialogs.py:65:35\n"},null]
[task 2023-05-17T10:30:54.482Z] 10:30:54     INFO -  1684319454483	Marionette	TRACE	Received observer notification common-dialog-loaded
[task 2023-05-17T10:30:54.497Z] 10:30:54     INFO -  1684319454502	Marionette	DEBUG	8 -> [0,41,"WebDriver:GetAlertText",{}]
[task 2023-05-17T10:30:54.503Z] 10:30:54     INFO -  1684319454502	Marionette	DEBUG	8 <- [1,41,null,{"value":"text"}]

Strangely there is no common-dialog-loaded observer notification sent but instead we get a DOMModalDialogClosed which means the prompt never got really opened. At this stage it is unclear what else might have caused the window / tab to close.

Can you help triage this :whimboo?

Flags: needinfo?(hskupin)

I'll move forward the needinfo to Dave given my last comment and the fact that the underlying page is unexpectedly getting unloaded. Note that these failures started around May 9th for Windows only as noted on bug 1816538 comment 9.

Flags: needinfo?(hskupin) → needinfo?(dtownsend)

As noticed by Julian the navigation that we expected is delayed and continue with the test before it actually has happened. When we are opening the alert the navigation promptly happens, and causes the prompt issues.

I assume that for this bug the code should simply return if contentWindow is null.

No longer blocks: 1816538

(In reply to Henrik Skupin [:whimboo][⌚️UTC+1] from comment #6)

As noticed by Julian the navigation that we expected is delayed and continue with the test before it actually has happened. When we are opening the alert the navigation promptly happens, and causes the prompt issues.

If I'm following correctly then my suggestion in comment 2 may be wrong and we could be opening the modal before the tab has finished loading its first page

I assume that for this bug the code should simply return if contentWindow is null.

I don't think that is the correct solution. It would hide the exception message but disguise the fact that we seem to be opening a modal at a bad time. We need to understand whether we're just doing it too soon or late in the tab's lifecycle because of the speed of the test, in which case the test needs to be adjusted accordingly, or if there is a more serious problem here.

Component: General → Notifications and Alerts
Flags: needinfo?(dtownsend)
Component: Notifications and Alerts → Content Prompts

The severity field is not set for this bug.
:mtigley, could you have a look please?

For more information, please visit BugBot documentation.

Flags: needinfo?(mtigley)
You need to log in before you can comment on or make changes to this bug.