From 2cd5e32cacd0d4be0a21442129c9332d1adfaa67 Mon Sep 17 00:00:00 2001 From: David Burns Date: Wed, 16 May 2012 13:44:24 -0700 Subject: [PATCH] Bug 755700 - Part A: test case, r=mdas, DONTBUILD because NPOTB --- .../tests/unit/test_window_switching.py | 45 +++++++++++++++++++ .../client/marionette/www/resultPage.html | 13 ++++++ .../client/marionette/www/test_windows.html | 10 +++++ 3 files changed, 68 insertions(+) create mode 100644 testing/marionette/client/marionette/tests/unit/test_window_switching.py create mode 100644 testing/marionette/client/marionette/www/resultPage.html create mode 100644 testing/marionette/client/marionette/www/test_windows.html diff --git a/testing/marionette/client/marionette/tests/unit/test_window_switching.py b/testing/marionette/client/marionette/tests/unit/test_window_switching.py new file mode 100644 index 00000000000..b6ca85c17c9 --- /dev/null +++ b/testing/marionette/client/marionette/tests/unit/test_window_switching.py @@ -0,0 +1,45 @@ +# 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 +import time +from marionette_test import MarionetteTestCase + +class TestWindowSwitching(MarionetteTestCase): + def testJSWindowCreationAndSwitching(self): + test_html = self.marionette.absolute_url("test_windows.html") + self.marionette.navigate(test_html) + + current_window = self.marionette.get_window() + link = self.marionette.find_element("link text", "Open new window") + link.click() + + windows = self.marionette.get_windows() + windows.remove(current_window) + self.marionette.switch_to_window(windows[0]) + + title = self.marionette.execute_script("return document.title") + results_page = self.marionette.absolute_url("resultPage.html") + self.assertEqual(self.marionette.get_url(), results_page) + self.assertEqual(title, "We Arrive Here") + + #ensure navigate works in our current window + other_page = self.marionette.absolute_url("test.html") + self.marionette.navigate(other_page) + other_window = self.marionette.get_window() + + #try to access its dom + #since Bug 720714 stops us from checking DOMContentLoaded, we wait a bit + for i in range(30): + try: + self.marionette.find_element("id", "mozLink") + break + except: + pass + time.sleep(1) + + self.assertEqual(other_window, self.marionette.get_window()) + self.marionette.switch_to_window(current_window) + self.assertEqual(current_window, self.marionette.get_window()) + diff --git a/testing/marionette/client/marionette/www/resultPage.html b/testing/marionette/client/marionette/www/resultPage.html new file mode 100644 index 00000000000..75b80acc9b4 --- /dev/null +++ b/testing/marionette/client/marionette/www/resultPage.html @@ -0,0 +1,13 @@ + + + We Arrive Here + + + + +
+ +
+ + + diff --git a/testing/marionette/client/marionette/www/test_windows.html b/testing/marionette/client/marionette/www/test_windows.html new file mode 100644 index 00000000000..3afb61d4c91 --- /dev/null +++ b/testing/marionette/client/marionette/www/test_windows.html @@ -0,0 +1,10 @@ + + + + XHTML Test Page + + +

Open new window

+ + +