зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1302707 - Fix type check to allow page loading timeout of 0; r=automatedtester
The `get` function in testing/marionette/listener.js used an evaluated if-condition test to determine if a page timeout was given. This would fail if passed 0 because 0 evaluates to false in JavaScript. This patch fixes the incorrect type check by looking at whether the variable has been defined or not. MozReview-Commit-ID: 39vDZRjKAFb --HG-- extra : rebase_source : f8100e05f9b1165e20b5aaab6e89b09fd110b3d2
This commit is contained in:
Родитель
a8388f63d6
Коммит
b2605976f0
|
@ -3,6 +3,7 @@
|
|||
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
|
||||
import os
|
||||
import time
|
||||
|
||||
from wptserve import server, handlers, routes as default_routes
|
||||
|
||||
|
@ -20,7 +21,8 @@ class FixtureServer(object):
|
|||
def start(self, block=False):
|
||||
if self.alive:
|
||||
return
|
||||
routes = [("POST", "/file_upload", upload_handler)]
|
||||
routes = [("POST", "/file_upload", upload_handler),
|
||||
("GET", "/slow", slow_loading_document)]
|
||||
routes.extend(default_routes.routes)
|
||||
self._server = server.WebTestHttpd(
|
||||
port=self.port,
|
||||
|
@ -57,6 +59,14 @@ def upload_handler(request, response):
|
|||
return 200, [], [request.headers.get("Content-Type")] or []
|
||||
|
||||
|
||||
@handlers.handler
|
||||
def slow_loading_document(request, response):
|
||||
time.sleep(5)
|
||||
return """<!doctype html>
|
||||
<title>ok</title>
|
||||
<p>ok"""
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
here = os.path.abspath(os.path.dirname(__file__))
|
||||
doc_root = os.path.join(os.path.dirname(here), "www")
|
||||
|
|
|
@ -122,18 +122,11 @@ class TestNavigate(MarionetteTestCase):
|
|||
self.assertEqual("complete", state)
|
||||
self.assertTrue(self.marionette.find_element(By.ID, "mozLink"))
|
||||
|
||||
def test_should_throw_a_timeoutexception_when_loading_page(self):
|
||||
try:
|
||||
def test_error_when_exceeding_page_load_timeout(self):
|
||||
with self.assertRaises(TimeoutException):
|
||||
self.marionette.set_page_load_timeout(0)
|
||||
self.marionette.navigate(self.test_doc)
|
||||
self.assertTrue(self.marionette.find_element(By.ID, "mozLink"))
|
||||
self.fail("Should have thrown a MarionetteException")
|
||||
except TimeoutException as e:
|
||||
self.assertTrue("Error loading page, timed out" in str(e))
|
||||
except Exception as e:
|
||||
import traceback
|
||||
print traceback.format_exc()
|
||||
self.fail("Should have thrown a TimeoutException instead of %s" % type(e))
|
||||
self.marionette.navigate(self.marionette.absolute_url("slow"))
|
||||
self.marionette.find_element(By.TAG_NAME, "p")
|
||||
|
||||
def test_navigate_iframe(self):
|
||||
self.marionette.navigate(self.iframe_doc)
|
||||
|
|
|
@ -908,7 +908,7 @@ function pollForReadyState(msg, start = undefined, callback = undefined) {
|
|||
*/
|
||||
function get(msg) {
|
||||
let start = new Date().getTime();
|
||||
let command_id = msg.json.command_id;
|
||||
let {pageTimeout, url, command_id} = msg.json;
|
||||
|
||||
let docShell = curContainer.frame
|
||||
.document
|
||||
|
@ -923,7 +923,7 @@ function get(msg) {
|
|||
let requestedURL;
|
||||
let loadEventExpected = false;
|
||||
try {
|
||||
requestedURL = new URL(msg.json.url).toString();
|
||||
requestedURL = new URL(url).toString();
|
||||
let curURL = curContainer.frame.location;
|
||||
loadEventExpected = navigate.isLoadEventExpected(curURL, requestedURL);
|
||||
} catch (e) {
|
||||
|
@ -1003,7 +1003,7 @@ function get(msg) {
|
|||
}
|
||||
};
|
||||
|
||||
if (msg.json.pageTimeout) {
|
||||
if (typeof pageTimeout != "undefined") {
|
||||
let onTimeout = function() {
|
||||
if (loadEventExpected) {
|
||||
removeEventListener("DOMContentLoaded", onDOMContentLoaded, false);
|
||||
|
@ -1011,7 +1011,7 @@ function get(msg) {
|
|||
webProgress.removeProgressListener(loadListener);
|
||||
sendError(new TimeoutError("Error loading page, timed out (onDOMContentLoaded)"), command_id);
|
||||
}
|
||||
navTimer.initWithCallback(onTimeout, msg.json.pageTimeout, Ci.nsITimer.TYPE_ONE_SHOT);
|
||||
navTimer.initWithCallback(onTimeout, pageTimeout, Ci.nsITimer.TYPE_ONE_SHOT);
|
||||
}
|
||||
|
||||
// in Firefox we need to move to the top frame before navigating
|
||||
|
|
Загрузка…
Ссылка в новой задаче