Closed Bug 1121671 Opened 9 years ago Closed 9 years ago

Intermittent browser_waitForFocus.js | Browser is focused when about:blank is loaded - Got [object XULElement], expected [object XULElement]

Categories

(Firefox :: General, defect)

x86_64
macOS
defect
Not set
normal
Points:
1

Tracking

()

RESOLVED FIXED
Firefox 40
Tracking Status
firefox38 --- wontfix
firefox39 --- fixed
firefox40 --- fixed
firefox-esr31 --- unaffected

People

(Reporter: RyanVM, Assigned: enndeakin)

Details

(Keywords: intermittent-failure)

Attachments

(1 file)

12:59:23 INFO - 177 INFO TEST-START | testing/mochitest/tests/browser/browser_waitForFocus.js
12:59:23 INFO - 178 INFO checking window state
12:59:23 INFO - 179 INFO TEST-PASS | testing/mochitest/tests/browser/browser_waitForFocus.js | I'm a test in head file
12:59:23 INFO - 180 INFO Entering test
12:59:23 INFO - 181 INFO must wait for load
12:59:23 INFO - 182 INFO TEST-UNEXPECTED-FAIL | testing/mochitest/tests/browser/browser_waitForFocus.js | Browser is focused when about:blank is loaded - Got [object XULElement], expected [object XULElement]
12:59:23 INFO - Stack trace:
12:59:23 INFO - chrome://mochikit/content/browser-test.js:test_is:851
12:59:23 INFO - chrome://mochitests/content/browser/testing/mochitest/tests/browser/browser_waitForFocus.js:null:33
12:59:23 INFO - self-hosted:InterpretGeneratorResume:677
12:59:23 INFO - self-hosted:next:585
12:59:23 INFO - Tester_execTest@chrome://mochikit/content/browser-test.js:667:9
12:59:23 INFO - Tester.prototype.nextTest</<@chrome://mochikit/content/browser-test.js:593:7
12:59:23 INFO - SimpleTest.waitForFocus/waitForFocusInner/focusedOrLoaded/<@chrome://mochikit/content/tests/SimpleTest/SimpleTest.js:750:59
12:59:23 INFO - 183 INFO Leaving test
12:59:23 INFO - 184 INFO Entering test
12:59:23 INFO - 185 INFO Console message: [JavaScript Warning: "unsafe CPOW usage" {file: "resource://app/modules/sessionstore/TabState.jsm" line: 96}]
12:59:23 INFO - 186 INFO Console message: [JavaScript Warning: "unsafe CPOW usage" {file: "resource://app/modules/sessionstore/TabState.jsm" line: 96}]
12:59:23 INFO - -*-*- UserCustomizations (child): document created: https://example.com/browser/testing/mochitest/tests/browser/waitForFocusPage.html
12:59:23 INFO - -*-*- UserCustomizations (child): _injectInWindow
12:59:23 INFO - -*-*- UserCustomizations (child): principal status: 0
12:59:23 INFO - -*-*- UserCustomizations (child): document created: data:text/plain,Test
12:59:23 INFO - -*-*- UserCustomizations (child): _injectInWindow
12:59:23 INFO - -*-*- UserCustomizations (child): principal status: 0
12:59:23 INFO - 187 INFO Console message: [JavaScript Error: "The character encoding of the HTML document was not declared. The document will render with garbled text in some browser configurations if the document contains characters from outside the US-ASCII range. The character encoding of the page must be declared in the document or in the transfer protocol." {file: "https://example.com/browser/testing/mochitest/tests/browser/waitForFocusPage.html" line: 0}]
12:59:23 INFO - 188 INFO Console message: [JavaScript Error: "The character encoding of the plain text document was not declared. The document will render with garbled text in some browser configurations if the document contains characters from outside the US-ASCII range. The character encoding of the file needs to be declared in the transfer protocol or file needs to use a byte order mark as an encoding signature." {file: "data:text/plain,Test" line: 0}]
12:59:23 INFO - 189 INFO Console message: [JavaScript Warning: "unsafe CPOW usage" {file: "resource://gre/modules/Promise.jsm -> resource://gre/modules/Promise-backend.js" line: 664}]
12:59:23 INFO - 190 INFO Console message: [JavaScript Warning: "unsafe CPOW usage" {file: "chrome://mochikit/content/tests/SimpleTest/SimpleTest.js" line: 830}]
12:59:23 INFO - 191 INFO Console message: [JavaScript Warning: "unsafe CPOW usage" {file: "chrome://mochikit/content/tests/SimpleTest/SimpleTest.js" line: 839}]
12:59:23 INFO - 192 INFO TEST-PASS | testing/mochitest/tests/browser/browser_waitForFocus.js | Browser is focused when page is loaded
12:59:23 INFO - 193 INFO Console message: [JavaScript Warning: "unsafe CPOW usage" {file: "resource://gre/modules/Promise.jsm -> resource://gre/modules/Promise-backend.js" line: 664}]
12:59:23 INFO - 194 INFO Console message: [JavaScript Warning: "unsafe CPOW usage" {file: "resource://gre/modules/Promise.jsm -> resource://gre/modules/Promise-backend.js" line: 664}]
12:59:23 INFO - 195 INFO Console message: [JavaScript Warning: "unsafe CPOW usage" {file: "chrome://mochitests/content/browser/testing/mochitest/tests/browser/browser_waitForFocus.js" line: 51}]
12:59:23 INFO - 196 INFO Console message: [JavaScript Warning: "unsafe CPOW usage" {file: "chrome://mochitests/content/browser/testing/mochitest/tests/browser/browser_waitForFocus.js" line: 51}]
12:59:23 INFO - 197 INFO Console message: [JavaScript Warning: "unsafe CPOW usage" {file: "chrome://mochikit/content/tests/SimpleTest/SimpleTest.js" line: 830}]
12:59:23 INFO - 198 INFO Console message: [JavaScript Warning: "unsafe CPOW usage" {file: "chrome://mochikit/content/tests/SimpleTest/SimpleTest.js" line: 839}]
12:59:23 INFO - 199 INFO TEST-PASS | testing/mochitest/tests/browser/browser_waitForFocus.js | Child iframe is focused
12:59:23 INFO - 200 INFO Leaving test
12:59:23 INFO - 201 INFO Console message: [JavaScript Warning: "unsafe CPOW usage" {file: "resource://gre/modules/Promise.jsm -> resource://gre/modules/Promise-backend.js" line: 664}]
12:59:23 INFO - 202 INFO Console message: [JavaScript Warning: "unsafe CPOW usage" {file: "resource://gre/modules/Promise.jsm -> resource://gre/modules/Promise-backend.js" line: 664}]
12:59:23 INFO - 203 INFO Console message: [JavaScript Warning: "unsafe CPOW usage" {file: "chrome://global/content/bindings/remote-browser.xml" line: 162}]
12:59:23 INFO - 204 INFO Console message: [JavaScript Warning: "unsafe CPOW usage" {file: "chrome://mochitests/content/browser/testing/mochitest/tests/browser/browser_waitForFocus.js" line: 53}]
12:59:23 INFO - 205 INFO Console message: [JavaScript Warning: "unsafe CPOW usage" {file: "chrome://mochitests/content/browser/testing/mochitest/tests/browser/browser_waitForFocus.js" line: 53}]
12:59:23 INFO - 206 INFO Console message: [JavaScript Warning: "unsafe CPOW usage" {file: "resource://app/modules/sessionstore/TabState.jsm" line: 96}]
12:59:23 INFO - 207 INFO Console message: [JavaScript Warning: "unsafe CPOW usage" {file: "resource://app/modules/sessionstore/TabState.jsm" line: 96}]
12:59:23 INFO - 208 INFO TEST-PASS | testing/mochitest/tests/browser/browser_waitForFocus.js | I'm a cleanup function in head file
12:59:23 INFO - 209 INFO TEST-PASS | testing/mochitest/tests/browser/browser_waitForFocus.js | Head cleanup function scope is correct
12:59:23 INFO - 210 INFO MEMORY STAT vsize after test: 3280494592
12:59:23 INFO - 211 INFO MEMORY STAT residentFast after test: 275079168
12:59:23 INFO - 212 INFO MEMORY STAT heapAllocated after test: 71787232
12:59:23 INFO - 213 INFO TEST-OK | testing/mochitest/tests/browser/browser_waitForFocus.js | took 624ms
Looks like this has picked up quite a bit, but still only on Mac. Almost certainly bug 1066531, since it also occurred regularly on March 20 when that patch was briefly checked in.
I'll take a look though on Monday.
Assignee: nobody → enndeakin
Status: NEW → ASSIGNED
I suspect this is another issue related to the odd focusing behaviour from bug 1108555. Essentially, trying to focus a new tab while it is opening is futile since focus shifts around several times.

Essentially, we need to wait for the focus event to occur after the TabSelect event has fired.
This failure seems to becaused by e10s' async tab switcher. if updateDisplay() calls _adjustFocusAfterTabSwitch() before the test checks the focus then we're good. In that case updateDisplay() is called by postActions(), called by requestTab(), the last caused by setting gBrowser.selectedTab at line 27 in the test.

adjustFocusAfterTabSwitch@chrome://browser/content/tabbrowser.xml:1235:51
_getSwitcher/switcher.updateDisplay@chrome://browser/content/tabbrowser.xml:3126:21
_getSwitcher/switcher.postActions@chrome://browser/content/tabbrowser.xml:3217:15
_getSwitcher/switcher.requestTab@chrome://browser/content/tabbrowser.xml:3333:15
set_selectedIndex@chrome://browser/content/tabbrowser.xml:5917:11
set_selectedPanel@chrome://global/content/bindings/tabbox.xml:671:13
set_selectedIndex@chrome://global/content/bindings/tabbox.xml:399:15
set_selectedItem@chrome://global/content/bindings/tabbox.xml:431:34
set_selectedTab@chrome://global/content/bindings/tabbox.xml:110:15
set_selectedTab@chrome://browser/content/tabbrowser.xml:2694:11
@chrome://mochitests/content/browser/testing/mochitest/tests/browser/browser_waitForFocus.js:27:3

Sometimes though switching takes longer and then the whole focus thing doesn't work out. This is quite reproducible on OS X 10.10 with the following command:

./mach build browser; while [ $? -eq 0 ]; do ./mach mochitest testing/mochitest/tests/browser/browser_waitForFocus.js --e10s --run-until-failure --repeat 3; done

Mike, you know the switcher very well, can you maybe dive into what's happening here? Or shed some more light?
Flags: needinfo?(mconley)
waitForFocus/promiseFocus expects to be able to focus a window by calling window.focus() which doesn't work well during a tab switch since the focus gets shuffled around a bit when switching tabs. Sometimes, the new tab will get focused, blurred and then focused again, and we actually want promiseFocus to return once all of this has settled.

Generally, we can fix the issue with tests by instead waiting for the TabSwitchDone event, as this has worked for some other tests with this problem. We should be able to do this here.
Attached patch waitforfocusfixSplinter Review
As described.
Since this is quite common, I checked this in to see if it helps:

https://hg.mozilla.org/integration/mozilla-inbound/rev/f2284790d81e
https://hg.mozilla.org/mozilla-central/rev/f2284790d81e
Status: ASSIGNED → RESOLVED
Closed: 9 years ago
Flags: in-testsuite+
Resolution: --- → FIXED
Target Milestone: --- → Firefox 40
Points: --- → 1
That wasn't a good idea.
https://hg.mozilla.org/releases/mozilla-beta/rev/ffb13ef5ff0a
Flags: needinfo?(mconley)
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: