Add history information to mozbrowserlocationchange event

This commit is contained in:
Paul Rouget 2016-03-21 19:19:48 +08:00
parent aa35d7721b
commit 6577409b95
8 changed files with 90 additions and 8 deletions

View file

@ -6024,6 +6024,12 @@
"url": "/_mozilla/mozilla/mozbrowser/mozbrowsericonchange_event.html"
}
],
"mozilla/mozbrowser/mozbrowserlocationchange_event.html": [
{
"path": "mozilla/mozbrowser/mozbrowserlocationchange_event.html",
"url": "/_mozilla/mozilla/mozbrowser/mozbrowserlocationchange_event.html"
}
],
"mozilla/mozbrowser/mozbrowsersecuritychange_event.html": [
{
"path": "mozilla/mozbrowser/mozbrowsersecuritychange_event.html",

View file

@ -19,8 +19,8 @@ async_test(function(t) {
iframe.src = url1;
iframe.addEventListener("mozbrowserlocationchange", e => {
locations.push(e.detail);
if (e.detail == url2) {
locations.push(e.detail.uri);
if (e.detail.uri == url2) {
iframe.goBack();
}
if (locations.length == expected_locations.length) {

View file

@ -0,0 +1,59 @@
<head>
<title>Browser API; mozbrowserlocationchange event</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
</head>
<body>
<script>
async_test(function(t) {
var url1 = "data:,1";
var url2 = "data:,2";
var url3 = "data:,3";
var received_events = []
var expected_events = [
url1, false, false,
url2, true, false,
url3, true, false,
url2, true, true,
url1, false, true,
url2, true, true,
url3, true, false,
];
var iframe = document.createElement("iframe");
iframe.mozbrowser = "true";
iframe.src = url1;
var actions = [
function() {iframe.src = url2},
function() {iframe.src = url3},
function() {iframe.goBack()},
function() {iframe.goBack()},
function() {iframe.goForward()},
function() {iframe.goForward()},
];
var action_idx = 0;
iframe.addEventListener("mozbrowserlocationchange", e => {
received_events.push(e.detail.uri);
received_events.push(e.detail.canGoBack);
received_events.push(e.detail.canGoForward);
if (action_idx < actions.length) {
actions[action_idx++]();
} else {
assert_array_equals(received_events, expected_events);
t.done();
}
});
document.body.appendChild(iframe);
});
</script>
</body>

View file

@ -10,7 +10,7 @@
iframe.mozbrowser = "true";
iframe.src = "redirect_init.html?pipe=status(302)|header(Location,redirect_final.html)";
iframe.addEventListener("mozbrowserlocationchange", t.step_func(e => {
assert_equals(e.detail, new URL("redirect_final.html", location).href);
assert_equals(e.detail.uri, new URL("redirect_final.html", location).href);
t.done();
}));
document.body.appendChild(iframe);