Bug 1279635 - Change mozbrowserlocationchange event detail to match Servo. r=smaug

MozReview-Commit-ID: 1kCbM5lJ4Sr

--HG--
extra : rebase_source : e13fb1ee68301e77acb0bd5b97f24deab865bdd8
This commit is contained in:
Kan-Ru Chen 2016-09-02 17:20:05 +08:00
Родитель 384eb5f086
Коммит 880bbbc173
11 изменённых файлов: 28 добавлений и 18 удалений

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

@ -1567,7 +1567,11 @@ BrowserElementChild.prototype = {
location = Cc["@mozilla.org/docshell/urifixup;1"]
.getService(Ci.nsIURIFixup).createExposableURI(location);
sendAsyncMsg('locationchange', { _payload_: location.spec });
var webNav = docShell.QueryInterface(Ci.nsIWebNavigation);
sendAsyncMsg('locationchange', { url: location.spec,
canGoBack: webNav.canGoBack,
canGoForward: webNav.canGoForward });
},
onStateChange: function(webProgress, request, stateFlags, status) {

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

@ -70,7 +70,9 @@ function test3() {
function test4() {
addOneShotIframeEventListener('mozbrowserlocationchange', function(e) {
is(e.detail, browserElementTestHelpers.emptyPage3);
is(e.detail.url, browserElementTestHelpers.emptyPage3);
is(e.detail.canGoBack, true);
is(e.detail.canGoForward, false);
checkCanGoBackAndForward(true, false, test5);
});
@ -81,7 +83,9 @@ function test4() {
function test5() {
addOneShotIframeEventListener('mozbrowserlocationchange', function(e) {
is(e.detail, browserElementTestHelpers.emptyPage2);
is(e.detail.url, browserElementTestHelpers.emptyPage2);
is(e.detail.canGoBack, true);
is(e.detail.canGoForward, true);
checkCanGoBackAndForward(true, true, test6);
});
iframe.goBack();
@ -89,7 +93,9 @@ function test5() {
function test6() {
addOneShotIframeEventListener('mozbrowserlocationchange', function(e) {
is(e.detail, browserElementTestHelpers.emptyPage1);
is(e.detail.url, browserElementTestHelpers.emptyPage1);
is(e.detail.canGoBack, false);
is(e.detail.canGoForward, true);
checkCanGoBackAndForward(false, true, SimpleTest.finish);
});
iframe.goBack();

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

@ -24,12 +24,12 @@ function runTest() {
document.body.appendChild(e.detail.frameElement);
e.detail.frameElement.addEventListener('mozbrowserlocationchange', function(e) {
if (e.detail == "http://example.com/#2") {
if (e.detail.url == "http://example.com/#2") {
ok(true, "Got locationchange to http://example.com/#2");
SimpleTest.finish();
}
else {
ok(true, "Got locationchange to " + e.detail);
ok(true, "Got locationchange to " + e.detail.url);
}
});

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

@ -36,7 +36,7 @@ function runTest2() {
ok(e.isTrusted, 'Event should be trusted.');
ok(!sawLocationChange, 'Just one locationchange event.');
ok(!sawLoadEnd, 'locationchange before load.');
is(e.detail, 'data:text/html,1', "event's reported location");
is(e.detail.url, 'data:text/html,1', "event's reported location");
sawLocationChange = true;
});

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

@ -13,7 +13,7 @@ var iframe;
function testPassword() {
function locationchange(e) {
var uri = e.detail;
var uri = e.detail.url;
is(uri, 'http://mochi.test:8888/tests/dom/browser-element/mochitest/file_empty.html',
"Username and password shouldn't be exposed in uri.");
SimpleTest.finish();
@ -33,7 +33,7 @@ function testWyciwyg() {
if (locationChangeCount == 0) {
locationChangeCount ++;
} else if (locationChangeCount == 1) {
var uri = e.detail;
var uri = e.detail.url;
is(uri, 'http://mochi.test:8888/tests/dom/browser-element/mochitest/file_wyciwyg.html', "Scheme in string shouldn't be wyciwyg");
iframe.removeEventListener('mozbrowserlocationchange', locationchange);
SimpleTest.executeSoon(testPassword);

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

@ -24,13 +24,13 @@ function runTest() {
});
iframe.addEventListener('mozbrowserlocationchange', function(e) {
if (e.detail == browserElementTestHelpers.emptyPage1) {
if (e.detail.url == browserElementTestHelpers.emptyPage1) {
gotFirstLocationChange = true;
if (gotFirstPaint) {
iframe.src = browserElementTestHelpers.emptyPage1 + '?2';
}
}
else if (e.detail.endsWith('?2')) {
else if (e.detail.url.endsWith('?2')) {
SimpleTest.finish();
}
});

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

@ -20,8 +20,8 @@ function runTest() {
});
iframe.addEventListener('mozbrowserlocationchange', function(e) {
ok(true, "Got locationchange to " + e.detail);
if (e.detail.endsWith("ForwardName.html#finish")) {
ok(true, "Got locationchange to " + e.detail.url);
if (e.detail.url.endsWith("ForwardName.html#finish")) {
SimpleTest.finish();
}
});

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

@ -38,7 +38,7 @@ function runTest() {
seenLocationChange = true;
ok(seenLoadStart, 'Location change after load start.');
ok(!seenLoadEnd, 'Location change before load end.');
ok(e.detail, browserElementTestHelpers.emptyPage1, "event's reported location");
ok(e.detail.url, browserElementTestHelpers.emptyPage1, "event's reported location");
}
function loadend(e) {
@ -91,7 +91,7 @@ function runTest2() {
seenLocationChange = true;
ok(seenLoadStart, 'Location change after load start.');
ok(!seenLoadEnd, 'Location change before load end.');
ok(e.detail, browserElementTestHelpers.emptyPage2, "event's reported location");
ok(e.detail.url, browserElementTestHelpers.emptyPage2, "event's reported location");
});
iframe.addEventListener('mozbrowserloadend', function(e) {

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

@ -75,7 +75,7 @@ function test3() {
function test4() {
addOneShotIframeEventListener('mozbrowserlocationchange', function(e) {
is(e.detail, browserElementTestHelpers.emptyPage3);
is(e.detail.url, browserElementTestHelpers.emptyPage3);
purgeHistory(SimpleTest.finish);
});

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

@ -35,7 +35,7 @@ function runTest() {
iframe.addEventListener("mozbrowserlocationchange", function onlocchange(e) {
var a = document.createElement("a");
a.href = e.detail;
a.href = e.detail.url;
switch (a.hash) {
case "#mousedown":

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

@ -18,7 +18,7 @@ function runTest() {
});
iframe.addEventListener('mozbrowserlocationchange', function(e) {
if (/file_browserElement_TargetTop.html\?2$/.test(e.detail)) {
if (/file_browserElement_TargetTop.html\?2$/.test(e.detail.url)) {
ok(true, 'Got the locationchange we were looking for.');
SimpleTest.finish();
}