Closed Bug 786094 Opened 8 years ago Closed 8 years ago
Tests that open new browser windows can get out of sync
Tests that open new browser windows and then perform chrome actions on them can get out of sync. This is because almost all of the chrome functions operate on the window returned by getCurrentWindow(), which just returns Services.wm.getMostRecentWindow() if no specific frame is active. So, a test can switch to a window, and then do something, but that new window might not be the one returned by Services.wm.getMostRecentWindow, since it takes some amount of time for a new window to be opened and put on top of the list used by getMostRecentWindow. We should really be tracking the current window across a session, instead of always attempting to use whatever window happens to be returned by getMostRecentWindow.
FYI in Mozmill we are using a window map to keep track of opened windows: https://github.com/mozilla/mozmill/blob/master/mozmill/mozmill/extension/resource/driver/controller.js#L32 https://github.com/mozilla/mozmill/blob/master/mozmill/mozmill/extension/resource/driver/mozmill.js#L318 https://github.com/mozilla/mozmill/blob/master/mozmill/mozmill/extension/resource/stdlib/utils.js#L91
This patch lets Marionette track chrome windows during a session, instead of always using the topmost window. This means we don't have to worry about timing issues when opening new windows, but we do have to explicitly call switch_to_window() after opening a new window if we want to operate on it. A nice side effect of this is we no longer have to focus windows to force them to the top of the getMostRecentWindow list, so when running tests, Firefox doesn't need to be in the foreground.
Attachment #655826 - Flags: review?(mdas)
Comment on attachment 655826 [details] [diff] [review] Track the current chrome window during a session, DONTBUILD because NPOTB Review of attachment 655826 [details] [diff] [review]: ----------------------------------------------------------------- love it! Should be good to go once we add the "self.assertNotEqual(self.win, self.marionette.current_window_handle)" line to all the setUp functions.
Attachment #655826 - Flags: review?(mdas) → review+
Review comments addressed and pushed as https://hg.mozilla.org/integration/mozilla-inbound/rev/ff1f9b1ddc2a
Assignee: nobody → jgriffin
Target Milestone: --- → mozilla18
Status: NEW → RESOLVED
Closed: 8 years ago
Resolution: --- → FIXED
You need to log in before you can comment on or make changes to this bug.