mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 577892 - allow icons to change when href attribute is set directly, with automated test, r=dolske,bz
--HG-- extra : rebase_source : 8b74cb3e4c60df4b84c207f2ae1bc371e238d19d
This commit is contained in:
parent
929d06afe2
commit
1207074468
@ -2842,7 +2842,7 @@ const DOMLinkHandler = {
|
||||
init: function() {
|
||||
let mm = window.messageManager;
|
||||
mm.addMessageListener("Link:AddFeed", this);
|
||||
mm.addMessageListener("Link:AddIcon", this);
|
||||
mm.addMessageListener("Link:SetIcon", this);
|
||||
mm.addMessageListener("Link:AddSearch", this);
|
||||
},
|
||||
|
||||
@ -2853,8 +2853,8 @@ const DOMLinkHandler = {
|
||||
FeedHandler.addFeed(link, aMsg.target);
|
||||
break;
|
||||
|
||||
case "Link:AddIcon":
|
||||
return this.addIcon(aMsg.target, aMsg.data.url);
|
||||
case "Link:SetIcon":
|
||||
return this.setIcon(aMsg.target, aMsg.data.url);
|
||||
break;
|
||||
|
||||
case "Link:AddSearch":
|
||||
@ -2863,7 +2863,7 @@ const DOMLinkHandler = {
|
||||
}
|
||||
},
|
||||
|
||||
addIcon: function(aBrowser, aURL) {
|
||||
setIcon: function(aBrowser, aURL) {
|
||||
if (gBrowser.isFailedIcon(aURL))
|
||||
return false;
|
||||
|
||||
|
@ -53,6 +53,7 @@ support-files =
|
||||
file_bug970276_favicon1.ico
|
||||
file_bug970276_favicon2.ico
|
||||
file_dom_notifications.html
|
||||
file_favicon_change.html
|
||||
file_fullscreen-window-open.html
|
||||
get_user_media.html
|
||||
head.js
|
||||
@ -290,6 +291,7 @@ skip-if = e10s # Bug 918663 - DOMLinkAdded events don't make their way to chrome
|
||||
[browser_duplicateIDs.js]
|
||||
[browser_drag.js]
|
||||
skip-if = true # browser_drag.js is disabled, as it needs to be updated for the new behavior from bug 320638.
|
||||
[browser_favicon_change.js]
|
||||
[browser_findbarClose.js]
|
||||
skip-if = e10s # Bug ?????? - test directly manipulates content (tries to grab an iframe directly from content)
|
||||
[browser_fullscreen-window-open.js]
|
||||
|
40
browser/base/content/test/general/browser_favicon_change.js
Normal file
40
browser/base/content/test/general/browser_favicon_change.js
Normal file
@ -0,0 +1,40 @@
|
||||
/* Any copyright is dedicated to the Public Domain.
|
||||
* http://creativecommons.org/publicdomain/zero/1.0/ */
|
||||
|
||||
"use strict";
|
||||
|
||||
const TEST_URL = "http://mochi.test:8888/browser/browser/base/content/test/general/file_favicon_change.html"
|
||||
|
||||
add_task(function*() {
|
||||
let extraTab = gBrowser.selectedTab = gBrowser.addTab();
|
||||
let tabLoaded = promiseTabLoaded(extraTab);
|
||||
extraTab.linkedBrowser.loadURI(TEST_URL);
|
||||
let expectedFavicon = "http://example.org/one-icon";
|
||||
let haveChanged = new Promise.defer();
|
||||
let observer = new MutationObserver(function(mutations) {
|
||||
for (let mut of mutations) {
|
||||
if (mut.attributeName != "image") {
|
||||
continue;
|
||||
}
|
||||
let imageVal = extraTab.getAttribute("image").replace(/#.*$/, "");
|
||||
if (!imageVal) {
|
||||
// The value gets removed because it doesn't load.
|
||||
continue;
|
||||
}
|
||||
is(imageVal, expectedFavicon, "Favicon image should correspond to expected image.");
|
||||
haveChanged.resolve();
|
||||
}
|
||||
});
|
||||
observer.observe(extraTab, {attributes: true});
|
||||
yield tabLoaded;
|
||||
yield haveChanged.promise;
|
||||
haveChanged = new Promise.defer();
|
||||
expectedFavicon = "http://example.org/other-icon";
|
||||
let contentWin = extraTab.linkedBrowser.contentWindow;
|
||||
let ev = new contentWin.CustomEvent("PleaseChangeFavicon", {});
|
||||
contentWin.dispatchEvent(ev);
|
||||
yield haveChanged.promise;
|
||||
observer.disconnect();
|
||||
gBrowser.removeTab(extraTab);
|
||||
});
|
||||
|
13
browser/base/content/test/general/file_favicon_change.html
Normal file
13
browser/base/content/test/general/file_favicon_change.html
Normal file
@ -0,0 +1,13 @@
|
||||
<!DOCTYPE html>
|
||||
<html><head>
|
||||
<meta http-equiv="content-type" content="text/html; charset=utf-8">
|
||||
<link rel="icon" href="http://example.org/one-icon" type="image/ico" id="i">
|
||||
</head>
|
||||
<body>
|
||||
<script>
|
||||
window.addEventListener("PleaseChangeFavicon", function() {
|
||||
var ico = document.getElementById("i");
|
||||
ico.setAttribute("href", "http://example.org/other-icon");
|
||||
});
|
||||
</script>
|
||||
</body></html>
|
@ -21,11 +21,14 @@ XPCOMUtils.defineLazyModuleGetter(this, "BrowserUtils",
|
||||
this.ContentLinkHandler = {
|
||||
init: function(chromeGlobal) {
|
||||
chromeGlobal.addEventListener("DOMLinkAdded", (event) => {
|
||||
this.onLinkAdded(event, chromeGlobal);
|
||||
this.onLinkEvent(event, chromeGlobal);
|
||||
}, false);
|
||||
chromeGlobal.addEventListener("DOMLinkChanged", (event) => {
|
||||
this.onLinkEvent(event, chromeGlobal);
|
||||
}, false);
|
||||
},
|
||||
|
||||
onLinkAdded: function(event, chromeGlobal) {
|
||||
onLinkEvent: function(event, chromeGlobal) {
|
||||
var link = event.originalTarget;
|
||||
var rel = link.rel && link.rel.toLowerCase();
|
||||
if (!link || !link.ownerDocument || !rel || !link.href)
|
||||
@ -47,7 +50,7 @@ this.ContentLinkHandler = {
|
||||
switch (relVal) {
|
||||
case "feed":
|
||||
case "alternate":
|
||||
if (!feedAdded) {
|
||||
if (!feedAdded && event.type == "DOMLinkAdded") {
|
||||
if (!rels.feed && rels.alternate && rels.stylesheet)
|
||||
break;
|
||||
|
||||
@ -69,11 +72,11 @@ this.ContentLinkHandler = {
|
||||
if (!uri)
|
||||
break;
|
||||
|
||||
[iconAdded] = chromeGlobal.sendSyncMessage("Link:AddIcon", {url: uri.spec});
|
||||
[iconAdded] = chromeGlobal.sendSyncMessage("Link:SetIcon", {url: uri.spec});
|
||||
}
|
||||
break;
|
||||
case "search":
|
||||
if (!searchAdded) {
|
||||
if (!searchAdded && event.type == "DOMLinkAdded") {
|
||||
var type = link.type && link.type.toLowerCase();
|
||||
type = type.replace(/^\s+|\s*(?:;.*)?$/g, "");
|
||||
|
||||
|
@ -320,6 +320,7 @@ HTMLLinkElement::SetAttr(int32_t aNameSpaceID, nsIAtom* aName,
|
||||
// to get updated information about the visitedness from Link.
|
||||
if (aName == nsGkAtoms::href && kNameSpaceID_None == aNameSpaceID) {
|
||||
Link::ResetLinkState(!!aNotify, true);
|
||||
CreateAndDispatchEvent(OwnerDoc(), NS_LITERAL_STRING("DOMLinkChanged"));
|
||||
}
|
||||
|
||||
if (NS_SUCCEEDED(rv) && aNameSpaceID == kNameSpaceID_None &&
|
||||
@ -382,6 +383,7 @@ HTMLLinkElement::UnsetAttr(int32_t aNameSpaceID, nsIAtom* aAttribute,
|
||||
// to get updated information about the visitedness from Link.
|
||||
if (aAttribute == nsGkAtoms::href && kNameSpaceID_None == aNameSpaceID) {
|
||||
Link::ResetLinkState(!!aNotify, false);
|
||||
CreateAndDispatchEvent(OwnerDoc(), NS_LITERAL_STRING("DOMLinkChanged"));
|
||||
}
|
||||
|
||||
return rv;
|
||||
|
Loading…
Reference in New Issue
Block a user