Closed Bug 755700 Opened 8 years ago Closed 8 years ago

Switching windows can cause the socket to fail.

Categories

(Testing :: Marionette, defect)

defect
Not set

Tracking

(blocking-kilimanjaro:+)

RESOLVED FIXED
mozilla15
blocking-kilimanjaro +

People

(Reporter: automatedtester, Assigned: mdas)

Details

Attachments

(2 files, 3 obsolete files)

If we have a window opened by javascript we can not access the elements on the page then we can access the DOM via execute script but can't access elements on the page
Attached patch test case to reproduce the issue (obsolete) — Splinter Review
Updating the bug, looks like moving to the new window really causes a socket timeout


1337199417155	Marionette	INFO	sendToClient: {"from":"conn18.marionette1","value":"285"}, undefined, null
1337199418248	Marionette	INFO	sendToClient: {"from":"conn18.marionette1","ok":true}, undefined, null
1337199418270	Marionette	INFO	sendToClient: {"from":"conn18.marionette1","value":"1"}, undefined, null
1337199420833	Marionette	INFO	sendToClient: {"from":"conn18.marionette1","value":"{84890edc-b93d-4482-84ea-0b7ed0fb85ad}"}, undefined, null
1337199439151	Marionette	INFO	sendToClient: {"from":"conn18.marionette1","ok":true}, undefined, null
1337199439376	Marionette	INFO	sendToClient: {"from":"conn18.marionette1","value":["1","289"]}, undefined, null
1337199439703	Marionette	INFO	sendToClient: {"from":"conn18.marionette1","ok":true}, undefined, null
1337199439756	Marionette	INFO	newSandbox: true
1337199619993	Marionette	INFO	sendToClient: {"from":"conn18.marionette1","ok":true}, undefined, null
Summary: If window opened by javascript link can't access elements on the page → Switching windows can cause the socket to fail.
Attached patch updated test case (obsolete) — Splinter Review
Updated the test case and made it more robust to prove the issue
Attachment #624361 - Attachment is obsolete: true
Test run output


(marionette)davidburns@ubuntu:~/mozilla-central$ python testing/marionette/client/marionette/runtests.py --type=browser --address=localhost:2828 testing/marionette/client/marionette/tests/unit/test_window_switching.py 
running webserver on http://192.168.114.129:53572/
TEST-START test_window_switching.py
testShouldSwitchFocusToANewWindowWhenItIsOpenedAndNotStopFutureOperations (test_window_switching.TestWindowSwitching) ... ERROR

======================================================================
ERROR: testShouldSwitchFocusToANewWindowWhenItIsOpenedAndNotStopFutureOperations (test_window_switching.TestWindowSwitching)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/davidburns/mozilla-central/testing/marionette/client/marionette/tests/unit/test_window_switching.py", line 53, in testShouldSwitchFocusToANewWindowWhenItIsOpenedAndNotStopFutureOperations
    title = self.marionette.execute_script("return document.title")
  File "/home/davidburns/mozilla-central/testing/marionette/client/marionette/marionette.py", line 340, in execute_script
    newSandbox=new_sandbox)
  File "/home/davidburns/mozilla-central/testing/marionette/client/marionette/marionette.py", line 169, in _send_message
    raise TimeoutException(message='socket.timeout', status=21, stacktrace=None)
TimeoutException: socket.timeout

----------------------------------------------------------------------
Ran 1 test in 182.160s

FAILED (errors=1)

SUMMARY
-------
passed: 0
failed: 1
todo: 0
This is a blocker for k9o because this prevents us from automating open web apps and browser ID using marionette (which is how we are architecting the QA automation).

Please push this to a high priority, mdas & Jgriffin.
blocking-kilimanjaro: --- → ?
a quick check to see if setting sandbox to False would affect it made no difference
Assignee: nobody → mdas
Attached patch updated test case v0.2 (obsolete) — Splinter Review
The test in the previous attachment navigated to test.html expecting to find an element with id 'email', but test.html does not have such an element. I changed this to look for the 'mozLink' element that's located on the test.html. 

So now, this test now clicks that link and opens the resultPage.html window, switches to it, confirms its title, then tries to navigate to test.html from within this new window, and verifies that it is in the right window and can search the dom of the new window.

Feel free to update the test if this isn't the gist of the test you were looking for.
Attachment #624525 - Attachment is obsolete: true
Attachment #624817 - Flags: review?(dburns)
Attached patch Fix v0.1Splinter Review
Our code assumed that you'd be loading a frame script if and only if you didn't have a content listener. This assumption was made so that you wouldn't reload a content listener when you're starting a new session in B2G (since we reuse the content listener in this case instead of starting a new one). I changed the check to make sure we load it if we don't have one, or we load it if we already have a session.
Attachment #624819 - Flags: review?(jgriffin)
Oh and the change on line 264 on marionette-actors.js is intentional; no one uses the returned winId.
uploaded the wrong file.
Attachment #624817 - Attachment is obsolete: true
Attachment #624817 - Flags: review?(dburns)
Attachment #624833 - Flags: feedback?
Attachment #624833 - Flags: feedback? → feedback?(dburns)
Comment on attachment 624833 [details] [diff] [review]
updated test case v0.3

Review of attachment 624833 [details] [diff] [review]:
-----------------------------------------------------------------

looks good, I had left 2 lines in by accident but this works just as well!
Attachment #624833 - Flags: feedback?(dburns) → feedback+
Comment on attachment 624819 [details] [diff] [review]
Fix v0.1

lgtm
Attachment #624819 - Flags: review?(jgriffin) → review+
https://hg.mozilla.org/mozilla-central/rev/6990b5f4ea25
https://hg.mozilla.org/mozilla-central/rev/69832fc16bd6
Status: NEW → RESOLVED
Closed: 8 years ago
Flags: in-testsuite-
Resolution: --- → FIXED
blocking-kilimanjaro: ? → +
You need to log in before you can comment on or make changes to this bug.