зеркало из https://github.com/mozilla/gecko-dev.git
Bug 741755 - Part 2: Add tests for getCanGo{Back,Forward} methods on <iframe mozbrowser>. r=mounir
This commit is contained in:
Родитель
bcd932aaed
Коммит
918aeb6421
|
@ -58,9 +58,12 @@ _TEST_FILES = \
|
|||
browserElement_SecurityChange.js \
|
||||
test_browserElement_inproc_SecurityChange.html \
|
||||
file_browserElement_SecurityChange.html \
|
||||
browserElement_CanGoBack.js \
|
||||
$(NULL)
|
||||
|
||||
# OOP tests don't work on Windows (bug 763081).
|
||||
#
|
||||
# Note that there's no inproc equivalent of CanGoBack; that's intentional.
|
||||
ifneq ($(OS_ARCH),WINNT)
|
||||
_TEST_FILES += \
|
||||
test_browserElement_oop_LoadEvents.html \
|
||||
|
@ -78,6 +81,7 @@ _TEST_FILES += \
|
|||
test_browserElement_oop_OpenWindow.html \
|
||||
test_browserElement_oop_OpenWindowRejected.html \
|
||||
test_browserElement_oop_SecurityChange.html \
|
||||
test_browserElement_oop_CanGoBack.html \
|
||||
$(NULL)
|
||||
endif
|
||||
|
||||
|
|
|
@ -0,0 +1,73 @@
|
|||
/* Any copyright is dedicated to the public domain.
|
||||
http://creativecommons.org/publicdomain/zero/1.0/ */
|
||||
|
||||
// Bug 741755 - Test that canGo{Back,Forward} works with <iframe mozbrowser>.
|
||||
|
||||
"use strict";
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
|
||||
var iframe;
|
||||
function runTest() {
|
||||
// At the moment, this isn't going to work unless we're actually out of
|
||||
// process.
|
||||
//
|
||||
// With in-process mozbrowser, the root SHistory for an <iframe mozbrowser>
|
||||
// crosses the mozbrowser boundary. It's like the mozbrowser wasn't there;
|
||||
// canGoBack reflects whether the top-level frame can go back, not whether the
|
||||
// iframe itself can go back.
|
||||
if (!browserElementTestHelpers.getOOPByDefaultPref()) {
|
||||
ok(false, "This test only works OOP.");
|
||||
return;
|
||||
}
|
||||
|
||||
browserElementTestHelpers.setEnabledPref(true);
|
||||
browserElementTestHelpers.addToWhitelist();
|
||||
|
||||
iframe = document.createElement('iframe');
|
||||
iframe.mozbrowser = true;
|
||||
|
||||
iframe.addEventListener('mozbrowserloadend', function loadend() {
|
||||
iframe.removeEventListener('mozbrowserloadend', loadend);
|
||||
SimpleTest.executeSoon(test2);
|
||||
});
|
||||
|
||||
iframe.src = browserElementTestHelpers.emptyPage1;
|
||||
document.body.appendChild(iframe);
|
||||
}
|
||||
|
||||
function checkCanGoBackAndForward(canGoBack, canGoForward, nextTest) {
|
||||
var seenCanGoBackResult = false;
|
||||
iframe.getCanGoBack().onsuccess = function(e) {
|
||||
is(seenCanGoBackResult, false, "onsuccess handler shouldn't be called twice.");
|
||||
seenCanGoBackResult = true;
|
||||
is(e.target.result, canGoBack);
|
||||
maybeRunNextTest();
|
||||
};
|
||||
|
||||
var seenCanGoForwardResult = false;
|
||||
iframe.getCanGoForward().onsuccess = function(e) {
|
||||
is(seenCanGoForwardResult, false, "onsuccess handler shouldn't be called twice.");
|
||||
seenCanGoForwardResult = true;
|
||||
is(e.target.result, canGoForward);
|
||||
maybeRunNextTest();
|
||||
};
|
||||
|
||||
function maybeRunNextTest() {
|
||||
if (seenCanGoBackResult && seenCanGoForwardResult) {
|
||||
nextTest();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function test2() {
|
||||
checkCanGoBackAndForward(/* canGoBack = */ false, /* canGoForward = */ false, test3);
|
||||
}
|
||||
|
||||
function test3() {
|
||||
iframe.addEventListener('mozbrowserloadend', function loadend() {
|
||||
checkCanGoBackAndForward(/* canGoBack = */ true, /* canGoForward = */ false, SimpleTest.finish);
|
||||
});
|
||||
iframe.src = browserElementTestHelpers.emptyPage2;
|
||||
}
|
||||
|
||||
runTest();
|
|
@ -0,0 +1,13 @@
|
|||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<head>
|
||||
<title>Test of browser element.</title>
|
||||
<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
|
||||
<script type="application/javascript" src="browserElementTestHelpers.js"></script>
|
||||
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
|
||||
</head>
|
||||
<body>
|
||||
<script type="application/javascript;version=1.7" src="browserElement_CanGoBack.js">
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
Загрузка…
Ссылка в новой задаче