Bug 1311657 - Switch to top-most frame first before closing chrome window.
MozReview-Commit-ID: 9Jf2gD1velz
--- a/testing/marionette/driver.js
+++ b/testing/marionette/driver.js
@@ -2236,16 +2236,19 @@ GeckoDriver.prototype.closeChromeWindow
// if there is only 1 window left, delete the session
if (nwins == 1) {
this.sessionTearDown();
return;
}
try {
+ // reset frame to the top-most frame
+ this.curFrame = null;
+
this.mm.removeDelayedFrameScript(FRAME_SCRIPT);
this.getCurrentWindow().close();
} catch (e) {
throw new UnknownError(`Could not close window: ${e.message}`);
}
};
/**
--- a/testing/marionette/harness/marionette_harness/tests/unit/test_anonymous_content.py
+++ b/testing/marionette/harness/marionette_harness/tests/unit/test_anonymous_content.py
@@ -1,14 +1,12 @@
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
-from unittest import skip
-
from marionette_driver.by import By
from marionette_driver.errors import NoSuchElementException
from marionette_driver.expected import element_present
from marionette_driver.marionette import HTMLElement
from marionette_driver.wait import Wait
from marionette_harness import MarionetteTestCase, WindowManagerMixin
@@ -36,17 +34,16 @@ class TestAnonymousContent(WindowManager
self.marionette.find_element(By.ID, "testAnonymousContentBox")
anon_browser_el = self.marionette.find_element(By.ID, "browser")
self.assertTrue("test_anonymous_content.xul" in self.marionette.get_url())
self.marionette.switch_to_frame(anon_browser_el)
self.assertTrue("test.xul" in self.marionette.get_url())
self.marionette.find_element(By.ID, "testXulBox")
self.assertRaises(NoSuchElementException, self.marionette.find_element, By.ID, "testAnonymousContentBox")
- @skip("Bug 1311657 - Opened chrome window cannot be closed after call to switch_to_frame")
def test_switch_to_anonymous_iframe(self):
self.marionette.find_element(By.ID, "testAnonymousContentBox")
el = self.marionette.find_element(By.ID, "container2")
anon_iframe_el = el.find_element(By.ANON_ATTRIBUTE, {"anonid": "iframe"})
self.marionette.switch_to_frame(anon_iframe_el)
self.assertTrue("test.xul" in self.marionette.get_url())
self.marionette.find_element(By.ID, "testXulBox")
self.assertRaises(NoSuchElementException, self.marionette.find_element, By.ID,
--- a/testing/marionette/harness/marionette_harness/tests/unit/test_switch_frame_chrome.py
+++ b/testing/marionette/harness/marionette_harness/tests/unit/test_switch_frame_chrome.py
@@ -1,14 +1,12 @@
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
-from unittest import skip
-
from marionette_driver.errors import JavascriptException
from marionette_harness import MarionetteTestCase, WindowManagerMixin
class TestSwitchFrameChrome(WindowManagerMixin, MarionetteTestCase):
def setUp(self):
@@ -24,17 +22,16 @@ class TestSwitchFrameChrome(WindowManage
new_window = self.open_window(trigger=open_window_with_js)
self.marionette.switch_to_window(new_window)
self.assertNotEqual(self.start_window, self.marionette.current_chrome_window_handle)
def tearDown(self):
self.close_all_windows()
super(TestSwitchFrameChrome, self).tearDown()
- @skip("Bug 1311657 - Opened chrome window cannot be closed after call to switch_to_frame(0)")
def test_switch_simple(self):
self.assertIn("test.xul", self.marionette.get_url(), "Initial navigation has failed")
self.marionette.switch_to_frame(0)
self.assertIn("test2.xul", self.marionette.get_url(),"Switching by index failed")
self.marionette.switch_to_frame()
self.assertEqual(None, self.marionette.get_active_frame(), "Switiching by null failed")
self.assertIn("test.xul", self.marionette.get_url(), "Switching by null failed")
self.marionette.switch_to_frame("iframe")
@@ -44,17 +41,16 @@ class TestSwitchFrameChrome(WindowManage
self.marionette.switch_to_frame("iframename")
self.assertIn("test2.xul", self.marionette.get_url(), "Switching by name failed")
iframe_element = self.marionette.get_active_frame()
self.marionette.switch_to_frame()
self.assertIn("test.xul", self.marionette.get_url(), "Switching by null failed")
self.marionette.switch_to_frame(iframe_element)
self.assertIn("test2.xul", self.marionette.get_url(), "Switching by element failed")
- @skip("Bug 1311657 - Opened chrome window cannot be closed after call to switch_to_frame(0)")
def test_stack_trace(self):
self.assertIn("test.xul", self.marionette.get_url(), "Initial navigation has failed")
self.marionette.switch_to_frame(0)
self.assertRaises(JavascriptException, self.marionette.execute_async_script, "foo();")
try:
self.marionette.execute_async_script("foo();")
except JavascriptException as e:
self.assertIn("foo", e.message)