Backed out changeset 6bb03867a3ad (bug 929175)
authorCarsten "Tomcat" Book <cbook@mozilla.com>
Fri, 25 Apr 2014 15:50:33 +0200
changeset 180152 83b46f317e111e08a2f930ba54b0dcf737592b7f
parent 180151 685e1c1a71ebfa4d381133d925d06851bd56085b
child 180153 59d2341b206a9aef08d508e6763094a309bf4507
push id1
push userroot
push dateMon, 20 Oct 2014 17:29:22 +0000
bugs929175
milestone31.0a1
backs out6bb03867a3adb440473efb256d7fd91a54a1dbec
Backed out changeset 6bb03867a3ad (bug 929175)
testing/marionette/client/marionette/tests/unit/test_switch_frame.py
testing/marionette/client/marionette/tests/unit/test_switch_remote_frame.py
testing/marionette/client/marionette/tests/unit/unit-tests.ini
testing/marionette/client/marionette/www/frameset.html
testing/marionette/client/marionette/www/framesetPage2.html
testing/marionette/client/marionette/www/test_iframe.html
--- a/testing/marionette/client/marionette/tests/unit/test_switch_frame.py
+++ b/testing/marionette/client/marionette/tests/unit/test_switch_frame.py
@@ -1,121 +1,77 @@
 # 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/.
 
+import os
 from marionette_test import MarionetteTestCase
 from marionette import JavascriptException
 
+# boiler plate for the initial navigation and frame switch
+def switch_to_window_verify(test, start_url, frame, verify_title, verify_url):
+    test.assertTrue(test.marionette.execute_script("window.location.href = 'about:blank'; return true;"))
+    test.assertEqual("about:blank", test.marionette.execute_script("return window.location.href;"))
+    test_html = test.marionette.absolute_url(start_url)
+    test.marionette.navigate(test_html)
+    test.assertEqual(test.marionette.get_active_frame(), None)
+    test.assertNotEqual("about:blank", test.marionette.execute_script("return window.location.href;"))
+    test.assertEqual(verify_title, test.marionette.title)
+    test.marionette.switch_to_default_content()
+    test.marionette.switch_to_frame(frame)
+    test.assertTrue(verify_url in test.marionette.get_url())
+    inner_frame_element = test.marionette.get_active_frame()
+    # test that we can switch back to main frame, then switch back to the
+    # inner frame with the value we got from get_active_frame
+    test.marionette.switch_to_frame()
+    test.assertEqual(verify_title, test.marionette.title)
+    test.marionette.switch_to_frame(inner_frame_element)
+    test.assertTrue(verify_url in test.marionette.get_url())
 
 class TestSwitchFrame(MarionetteTestCase):
     def test_switch_simple(self):
-        start_url = "test_iframe.html"
-        verify_title = "Marionette IFrame Test"
-        verify_url = "test.html"
-        test_html = self.marionette.absolute_url(start_url)
-        self.marionette.navigate(test_html)
-        self.assertEqual(self.marionette.get_active_frame(), None)
-        frame = self.marionette.find_element("id", "test_iframe")
-        self.marionette.switch_to_frame(frame)
-        self.assertTrue(verify_url in self.marionette.get_url())
-        inner_frame_element = self.marionette.get_active_frame()
-        # test that we can switch back to main frame, then switch back to the
-        # inner frame with the value we got from get_active_frame
-        self.marionette.switch_to_frame()
-        self.assertEqual(verify_title, self.marionette.title)
-        self.marionette.switch_to_frame(inner_frame_element)
-        self.assertTrue(verify_url in self.marionette.get_url())
+        switch_to_window_verify(self, "test_iframe.html", "test_iframe", "Marionette IFrame Test", "test.html")
 
     def test_switch_nested(self):
-        start_url = "test_nested_iframe.html"
-        verify_title = "Marionette IFrame Test"
-        verify_url = "test_inner_iframe.html"
-        test_html = self.marionette.absolute_url(start_url)
-        self.marionette.navigate(test_html)
-        frame = self.marionette.find_element("id", "test_iframe")
-        self.assertEqual(self.marionette.get_active_frame(), None)
-        self.marionette.switch_to_frame(frame)
-        self.assertTrue(verify_url in self.marionette.get_url())
-        inner_frame_element = self.marionette.get_active_frame()
-        # test that we can switch back to main frame, then switch back to the
-        # inner frame with the value we got from get_active_frame
-        self.marionette.switch_to_frame()
-        self.assertEqual(verify_title, self.marionette.title)
-        self.marionette.switch_to_frame(inner_frame_element)
-        self.assertTrue(verify_url in self.marionette.get_url())
-        inner_frame = self.marionette.find_element('id', 'inner_frame')
-        self.marionette.switch_to_frame(inner_frame)
+        switch_to_window_verify(self, "test_nested_iframe.html", "test_iframe", "Marionette IFrame Test", "test_inner_iframe.html")
+        self.marionette.switch_to_frame("inner_frame")
         self.assertTrue("test.html" in self.marionette.get_url())
         self.marionette.switch_to_frame() # go back to main frame
         self.assertTrue("test_nested_iframe.html" in self.marionette.get_url())
         #test that we're using the right window object server-side
         self.assertTrue("test_nested_iframe.html" in self.marionette.execute_script("return window.location.href;"))
 
     def test_stack_trace(self):
-        start_url = "test_iframe.html"
-        verify_title = "Marionette IFrame Test"
-        verify_url = "test.html"
-        test_html = self.marionette.absolute_url(start_url)
-        self.marionette.navigate(test_html)
-        frame = self.marionette.find_element("id", "test_iframe")
-        self.assertEqual(self.marionette.get_active_frame(), None)
-        self.marionette.switch_to_frame(frame)
-        self.assertTrue(verify_url in self.marionette.get_url())
-        inner_frame_element = self.marionette.get_active_frame()
-        # test that we can switch back to main frame, then switch back to the
-        # inner frame with the value we got from get_active_frame
-        self.marionette.switch_to_frame()
-        self.assertEqual(verify_title, self.marionette.title)
-        self.marionette.switch_to_frame(inner_frame_element)
-        self.assertTrue(verify_url in self.marionette.get_url())
-
+        switch_to_window_verify(self, "test_iframe.html", "test_iframe", "Marionette IFrame Test", "test.html")
         #can't use assertRaises in context manager with python2.6
         self.assertRaises(JavascriptException, self.marionette.execute_async_script, "foo();")
         try:
             self.marionette.execute_async_script("foo();")
         except JavascriptException as e:
             self.assertTrue("foo" in e.msg)
 
-    def test_should_be_able_to_carry_on_working_if_the_frame_is_deleted_from_under_us(self):
+    def testShouldBeAbleToCarryOnWorkingIfTheFrameIsDeletedFromUnderUs(self):
         test_html = self.marionette.absolute_url("deletingFrame.html")
         self.marionette.navigate(test_html)
 
-        self.marionette.switch_to_frame(self.marionette.find_element('id',
-                                                                     'iframe1'))
-        killIframe = self.marionette.find_element("id", "killIframe")
+        self.marionette.switch_to_frame("iframe1");
+        killIframe = self.marionette.find_element("id" ,"killIframe")
         killIframe.click()
         self.marionette.switch_to_frame()
 
         self.assertEqual(0, len(self.marionette.find_elements("id", "iframe1")))
 
         addIFrame = self.marionette.find_element("id", "addBackFrame")
         addIFrame.click()
         self.marionette.find_element("id", "iframe1")
 
-        self.marionette.switch_to_frame(self.marionette.find_element("id",
-                                                                     "iframe1"))
+        self.marionette.switch_to_frame("iframe1");
 
         self.marionette.find_element("id", "checkbox")
 
-    def test_should_allow_a_user_to_switch_from_an_iframe_back_to_the_main_content_of_the_page(self):
+    def testShouldAllowAUserToSwitchFromAnIframeBackToTheMainContentOfThePage(self):
         test_iframe = self.marionette.absolute_url("test_iframe.html")
         self.marionette.navigate(test_iframe)
         self.marionette.switch_to_frame(0)
         self.marionette.switch_to_default_content()
         header = self.marionette.find_element("id", "iframe_page_heading")
         self.assertEqual(header.text, "This is the heading")
 
-    def test_should_be_able_to_switch_to_a_frame_by_its_index(self):
-        test_html = self.marionette.absolute_url("frameset.html")
-        self.marionette.navigate(test_html)
-        self.marionette.switch_to_frame(2)
-        element = self.marionette.find_element("id", "email")
-        self.assertEquals("email", element.get_attribute("type"))
-
-    def test_should_be_able_to_switch_to_a_frame_using_a_previously_located_element(self):
-        test_html = self.marionette.absolute_url("frameset.html")
-        self.marionette.navigate(test_html)
-        frame = self.marionette.find_element("name", "third")
-        self.marionette.switch_to_frame(frame)
-
-        element = self.marionette.find_element("id", "email")
-        self.assertEquals("email", element.get_attribute("type"))
--- a/testing/marionette/client/marionette/tests/unit/test_switch_remote_frame.py
+++ b/testing/marionette/client/marionette/tests/unit/test_switch_remote_frame.py
@@ -35,18 +35,17 @@ class TestSwitchRemoteFrame(MarionetteTe
             SpecialPowers.wrap(iframe).mozbrowser = true;
             SpecialPowers.wrap(iframe).remote = true;
             iframe.id = "remote_iframe";
             iframe.style.height = "100px";
             iframe.style.width = "100%%";
             iframe.src = "%s";
             document.body.appendChild(iframe);
             """ % self.marionette.absolute_url("test.html"))
-        remote_iframe = self.marionette.find_element("id", "remote_iframe")
-        self.marionette.switch_to_frame(remote_iframe)
+        self.marionette.switch_to_frame("remote_iframe")
         main_process = self.marionette.execute_script("""
             return SpecialPowers.isMainProcess();
             """)
         self.assertFalse(main_process)
 
     def test_remote_frame_revisit(self):
         # test if we can revisit a remote frame (this takes a different codepath)
         self.marionette.navigate(self.marionette.absolute_url("test.html"))
@@ -56,29 +55,27 @@ class TestSwitchRemoteFrame(MarionetteTe
             SpecialPowers.wrap(iframe).mozbrowser = true;
             SpecialPowers.wrap(iframe).remote = true;
             iframe.id = "remote_iframe";
             iframe.style.height = "100px";
             iframe.style.width = "100%%";
             iframe.src = "%s";
             document.body.appendChild(iframe);
             """ % self.marionette.absolute_url("test.html"))
-        self.marionette.switch_to_frame(self.marionette.find_element("id",
-                                                                     "remote_iframe"))
+        self.marionette.switch_to_frame("remote_iframe")
         main_process = self.marionette.execute_script("""
             return SpecialPowers.isMainProcess();
             """)
         self.assertFalse(main_process)
         self.marionette.switch_to_frame()
         main_process = self.marionette.execute_script("""
             return SpecialPowers.isMainProcess();
             """)
         self.assertTrue(main_process)
-        self.marionette.switch_to_frame(self.marionette.find_element("id",
-                                                                     "remote_iframe"))
+        self.marionette.switch_to_frame("remote_iframe")
         main_process = self.marionette.execute_script("""
             return SpecialPowers.isMainProcess();
             """)
         self.assertFalse(main_process)
 
     def tearDown(self):
         if self.oop_by_default is None:
             self.marionette.execute_script("""
--- a/testing/marionette/client/marionette/tests/unit/unit-tests.ini
+++ b/testing/marionette/client/marionette/tests/unit/unit-tests.ini
@@ -80,17 +80,17 @@ browser = false
 [test_simpletest_pass.js]
 [test_simpletest_sanity.py]
 [test_simpletest_chrome.js]
 [test_simpletest_timeout.js]
 [test_specialpowers.py]
 [test_switch_frame.py]
 [test_switch_frame_chrome.py]
 [test_switch_remote_frame.py]
-browser = false
+
 [test_pagesource.py]
 
 [test_visibility.py]
 [test_window_switching.py]
 b2g = false
 [test_window_management.py]
 b2g = false
 
deleted file mode 100644
--- a/testing/marionette/client/marionette/www/frameset.html
+++ /dev/null
@@ -1,14 +0,0 @@
-<html>
-  <head>
-    <title>Unique title</title>
-  </head>
-<frameset cols="*, *, *, *, *, *, *">
-    <frame name="first" src="page/1"/>
-    <frame name="second" src="page/2?title=Fish"/>
-    <frame name="third" src="formPage.html"/>
-    <frame name="fourth" src="framesetPage2.html"/>
-    <frame id="fifth" src="xhtmlTest.html"/>
-    <frame id="sixth" src="iframes.html"/>
-    <frame id="sixth.iframe1" src="page/3"/>
-</frameset>
-</html>
\ No newline at end of file
deleted file mode 100644
--- a/testing/marionette/client/marionette/www/framesetPage2.html
+++ /dev/null
@@ -1,7 +0,0 @@
-<html>
-<head></head>
-<frameset cols="*, *">
-    <frame name="child1" src="page/10"/>
-    <frame name="child2" src="page/11"/>
-</frameset>
-</html>
\ No newline at end of file
--- a/testing/marionette/client/marionette/www/test_iframe.html
+++ b/testing/marionette/client/marionette/www/test_iframe.html
@@ -6,11 +6,10 @@
 <html>
 <head>
 <title>Marionette IFrame Test</title>
 </head>
 <body>
   <h1 id="iframe_page_heading">This is the heading</h1>
 
   <iframe src="test.html" id="test_iframe"></iframe>
-  <iframe src="test.html" id="test_iframe" name="test_iframe_name"></iframe>
 </body>
 </html>