From a641e6246c36dd224ce34c124fe6d1214b12e686 Mon Sep 17 00:00:00 2001 From: Chris Manchester Date: Fri, 12 Dec 2014 12:08:32 -0500 Subject: [PATCH] Bug 1099331 - Allow navigation resulting in about:blocked or about:error pages when explicitly requested without returning an error from the marionette server.;r=automatedtester This allows navigation resulting in a blocked or error page without returning an error to the client. If an error page is reached, an error is returned in cases this was not specifically requested in the client: client.navigate("about:neterror") will navigate to this page and return to the client without an error, but client.navigate("does.not.exist.") will return to the client with an error as it has previously. --- .../marionette/tests/unit/test_navigation.py | 8 ++++++++ testing/marionette/marionette-listener.js | 16 ++++++++++------ 2 files changed, 18 insertions(+), 6 deletions(-) diff --git a/testing/marionette/client/marionette/tests/unit/test_navigation.py b/testing/marionette/client/marionette/tests/unit/test_navigation.py index adb6c456fe25..2d80eae4f40b 100644 --- a/testing/marionette/client/marionette/tests/unit/test_navigation.py +++ b/testing/marionette/client/marionette/tests/unit/test_navigation.py @@ -90,6 +90,14 @@ class TestNavigate(MarionetteTestCase): print traceback.format_exc() self.fail("Should have thrown a MarionetteException instead of %s" % type(inst)) + @skip_if_b2g # about:blocked isn't a well formed uri on b2g + def test_should_navigate_to_requested_about_page(self): + self.marionette.navigate("about:neterror") + self.assertEqual(self.marionette.get_url(), "about:neterror") + self.marionette.navigate(self.marionette.absolute_url("test.html")) + self.marionette.navigate("about:blocked") + self.assertEqual(self.marionette.get_url(), "about:blocked") + def test_find_element_state_complete(self): test_html = self.marionette.absolute_url("test.html") self.marionette.navigate(test_html) diff --git a/testing/marionette/marionette-listener.js b/testing/marionette/marionette-listener.js index c6f39a38565f..926ee2a3fe4c 100644 --- a/testing/marionette/marionette-listener.js +++ b/testing/marionette/marionette-listener.js @@ -1281,19 +1281,23 @@ function get(msg) { function checkLoad() { checkTimer.cancel(); end = new Date().getTime(); - let errorRegex = /about:.+(error)|(blocked)\?/; + let aboutErrorRegex = /about:.+(error)\?/; let elapse = end - start; if (msg.json.pageTimeout == null || elapse <= msg.json.pageTimeout) { if (curFrame.document.readyState == "complete") { removeEventListener("DOMContentLoaded", onDOMContentLoaded, false); sendOk(command_id); - } - else if (curFrame.document.readyState == "interactive" && - errorRegex.exec(curFrame.document.baseURI)) { + } else if (curFrame.document.readyState == "interactive" && + aboutErrorRegex.exec(curFrame.document.baseURI) && + !curFrame.document.baseURI.startsWith(msg.json.url)) { + // We have reached an error url without requesting it. removeEventListener("DOMContentLoaded", onDOMContentLoaded, false); sendError("Error loading page", 13, null, command_id); - } - else { + } else if (curFrame.document.readyState == "interactive" && + curFrame.document.baseURI.startsWith("about:")) { + removeEventListener("DOMContentLoaded", onDOMContentLoaded, false); + sendOk(command_id); + } else { checkTimer.initWithCallback(checkLoad, 100, Ci.nsITimer.TYPE_ONE_SHOT); } }