Closed Bug 1366988 Opened 7 years ago Closed 6 years ago

GeckoDriver#registerBrowser does not check if tab browser is available before getting

Categories

(Remote Protocol :: Marionette, defect, P4)

53 Branch
defect

Tracking

(Not tracked)

RESOLVED DUPLICATE of bug 1311041

People

(Reporter: markus.hartung, Unassigned)

Details

User Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/59.0.3071.61 Safari/537.36

Steps to reproduce:

https://github.com/markus-hartung-avira/marionette-popup-bug

Run the PopupTest class to run the test.

The test does the following:
1. Start a Firefox session with an extension installed
2. Click the extension icon which opens the popup
3. Check if an element is displayed in the popup
4. Close the popup by sending escape key
5. Check if the extension icon is displayed

I tested this with FF53 and FF54




Actual results:

After step 4 the following error is logged:
JavaScript error: chrome://marionette/content/driver.js, line 523: TypeError: be.getTabBrowser is not a function

Executing step 5 results in:
*************************
A coding exception was thrown and uncaught in a Task.

Full message: TypeError: can't access dead object
Full stack: 
*************************
*************************
A coding exception was thrown and uncaught in a Task.

Full message: TypeError: can't access dead object
Full stack: 
*************************
*************************
A coding exception was thrown in a Promise rejection callback.
See https://developer.mozilla.org/Mozilla/JavaScript_code_modules/Promise.jsm/Promise

Full message: TypeError: can't access dead object
Full stack: 
*************************
Marionette threw an error: TypeError: can't access dead object

Exception in thread "main" org.openqa.selenium.WebDriverException: TypeError: can't access dead object
Build info: version: '3.4.0', revision: 'unknown', time: 'unknown'
System info: host: 'LTTW0350', ip: '169.254.244.75', os.name: 'Windows 10', os.arch: 'amd64', os.version: '10.0', java.version: '1.8.0_101'
Driver info: FirefoxDriver
Capabilities: Not needed.
Session ID: caa4a718-335f-4864-ba40-94c9e049b7c6
	at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
	at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
	at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
	at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
	at org.openqa.selenium.remote.http.W3CHttpResponseCodec.createException(W3CHttpResponseCodec.java:150)
	at org.openqa.selenium.remote.http.W3CHttpResponseCodec.decode(W3CHttpResponseCodec.java:115)
	at org.openqa.selenium.remote.http.W3CHttpResponseCodec.decode(W3CHttpResponseCodec.java:45)
	at org.openqa.selenium.remote.HttpCommandExecutor.execute(HttpCommandExecutor.java:164)
	at org.openqa.selenium.remote.service.DriverCommandExecutor.execute(DriverCommandExecutor.java:82)
	at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:637)
	at FirefoxDriver.execute(FirefoxDriver.java:33)
	at org.openqa.selenium.remote.RemoteWebElement.execute(RemoteWebElement.java:272)
	at org.openqa.selenium.remote.RemoteWebElement.isDisplayed(RemoteWebElement.java:313)
	at PopupTest.main(PopupTest.java:48)






Expected results:

isDisplayed should have returned true
And does this happen on Firefox Nightly?

be.getTabBrowser is called in GeckoDriver#registerBrowser (https://searchfox.org/mozilla-central/rev/6c2dbacbba1d58b8679cee700fd0a54189e0cf1b/testing/marionette/driver.js#518), which means this isn’t directly related to the Is Element Displayed command, but is instead associated with the code that is run when a content frame script (testing/marionette/listener.js) registers with the chrome context.  This happens whenever a new <xul:browser> appears.
Priority: -- → P4
Yes it is the same issue on Nightly.
I extended the check in the driver to
if (this.appName != "Firefox" || be.namespaceURI != XUL_NS ||
      be.nodeName != "browser" || (be.getTabBrowser && be.getTabBrowser())) {

so that it doesn't throw an error.

But the subsequent isDisplayed will still throw the same error
(In reply to Markus Hartung from comment #3)
> I extended the check in the driver to
> if (this.appName != "Firefox" || be.namespaceURI != XUL_NS ||
>       be.nodeName != "browser" || (be.getTabBrowser && be.getTabBrowser())) {

That seems like an OK change to make.  Please feel free to submit a patch.

> But the subsequent isDisplayed will still throw the same error

That would be a separate bug.
Summary: Closing extension popup breaks isDisplayed → GeckoDriver#registerBrowser does not check if tab browser is available before getting
This will get resolved as part of https://bugzil.la/marionette-window-tracking.
Status: UNCONFIRMED → RESOLVED
Closed: 6 years ago
Resolution: --- → DUPLICATE
Product: Testing → Remote Protocol
You need to log in before you can comment on or make changes to this bug.