Bug 1323451 - Fix test failures in test_navigation.py for Fennec. r=ato

MozReview-Commit-ID: 9YmBJIp0vAJ

--HG--
extra : rebase_source : d58536432a9271ac197ec6838e08785a42d8ecf6
This commit is contained in:
Henrik Skupin 2016-12-15 17:00:20 +01:00
Родитель f3e89595f1
Коммит a2a8f73530
2 изменённых файлов: 9 добавлений и 41 удалений

Просмотреть файл

@ -1023,46 +1023,11 @@ GeckoDriver.prototype.get = function*(cmd, resp) {
break;
case Context.CHROME:
// At least on desktop, navigating in chrome scope does not
// correspond to something a user can do, and leaves marionette
// and the browser in an unusable state. Return a generic error insted.
// TODO: Error codes need to be refined as a part of bug 1100545 and
// bug 945729.
if (this.appName == "Firefox") {
throw new UnknownError("Cannot navigate in chrome context");
}
this.getCurrentWindow().location.href = url;
yield this.pageLoadPromise();
throw new UnsupportedOperationError("Cannot navigate in chrome context");
break;
}
};
GeckoDriver.prototype.pageLoadPromise = function() {
let win = this.getCurrentWindow();
let timeout = this.pageTimeout;
let checkTimer = Cc["@mozilla.org/timer;1"].createInstance(Ci.nsITimer);
let start = new Date().getTime();
let end = null;
return new Promise((resolve) => {
let checkLoad = function() {
end = new Date().getTime();
let elapse = end - start;
if (timeout === null || elapse <= timeout) {
if (win.document.readyState == "complete") {
resolve();
} else {
checkTimer.initWithCallback(checkLoad, 100, Ci.nsITimer.TYPE_ONE_SHOT);
}
} else {
throw new UnknownError("Error loading page");
}
};
checkTimer.initWithCallback(checkLoad, 100, Ci.nsITimer.TYPE_ONE_SHOT);
});
};
/**
* Get a string representing the current URL.
*

Просмотреть файл

@ -2,13 +2,15 @@
# 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
import contextlib
import time
import urllib
from marionette_driver import errors, By, Wait
from marionette_harness import MarionetteTestCase, WindowManagerMixin
from marionette_harness import MarionetteTestCase, skip_if_mobile, WindowManagerMixin
def inline(doc):
@ -48,8 +50,8 @@ class TestNavigate(WindowManagerMixin, MarionetteTestCase):
def test_navigate_chrome_error(self):
with self.marionette.using_context("chrome"):
self.assertRaisesRegexp(
errors.MarionetteException, "Cannot navigate in chrome context",
self.marionette.navigate, "about:blank")
errors.UnsupportedOperationException, "Cannot navigate in chrome context",
self.marionette.navigate, "about:blank")
def test_get_current_url_returns_top_level_browsing_context_url(self):
self.marionette.navigate(self.iframe_doc)
@ -101,7 +103,7 @@ class TestNavigate(WindowManagerMixin, MarionetteTestCase):
self.assertTrue(self.marionette.execute_script(
"return window.document.getElementById('someDiv') == undefined"))
""" Disabled due to Bug 977899
@skip("Disabled due to Bug 977899")
def test_navigate_frame(self):
self.marionette.navigate(self.marionette.absolute_url("test_iframe.html"))
self.marionette.switch_to_frame(0)
@ -109,8 +111,8 @@ class TestNavigate(WindowManagerMixin, MarionetteTestCase):
self.assertTrue('empty.html' in self.marionette.get_url())
self.marionette.switch_to_frame()
self.assertTrue('test_iframe.html' in self.marionette.get_url())
"""
@skip_if_mobile # Bug 1323755 - Socket timeout
def test_invalid_protocol(self):
with self.assertRaises(errors.MarionetteException):
self.marionette.navigate("thisprotocoldoesnotexist://")
@ -148,6 +150,7 @@ class TestNavigate(WindowManagerMixin, MarionetteTestCase):
self.assertTrue(self.marionette.execute_script(
"return window.visited", sandbox=None))
@skip_if_mobile # Fennec doesn't support other chrome windows
def test_about_blank_for_new_docshell(self):
""" Bug 1312674 - Hang when loading about:blank for a new docshell."""
# Open a window to get a new docshell created for the first tab