Auto merge of #8449 - paulrouget:favicon, r=jdm

mozbrowsericonchange event (Browser API)

fixes #8347

<!-- Reviewable:start -->
[<img src="https://reviewable.io/review_button.png" height=40 alt="Review on Reviewable"/>](https://reviewable.io/reviews/servo/servo/8449)
<!-- Reviewable:end -->
This commit is contained in:
bors-servo 2015-11-14 19:54:03 +05:30
commit 7f076c628b
8 changed files with 154 additions and 25 deletions

View file

@ -5009,6 +5009,12 @@
"url": "/_mozilla/mozilla/load_event.html"
}
],
"mozilla/mozbrowser/mozbrowsericonchange_event.html": [
{
"path": "mozilla/mozbrowser/mozbrowsericonchange_event.html",
"url": "/_mozilla/mozilla/mozbrowser/mozbrowsericonchange_event.html"
}
],
"mozilla/navigator.html": [
{
"path": "mozilla/navigator.html",

View file

@ -0,0 +1 @@
prefs: ["dom.mozbrowser.enabled:true"]

View file

@ -0,0 +1,51 @@
<head>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
</head>
<body>
<script>
async_test(function(t) {
var expectedEvents = [
{rel: "icon", href: "http://web-platform.test:8000/test1.ico", sizes: "any"},
{rel: "icon", href: "http://web-platform.test:8000/_mozilla/mozilla/mozbrowser/test2.ico", sizes: "16x16 24x24"},
{rel: "shortcut icon", href: "http://example.com/test3.ico", sizes: ""},
{rel: "apple-touch-icon", href: "http://web-platform.test:8000/test4.ico", sizes: ""},
{rel: "icon", href: "http://web-platform.test:8000/test5.ico", sizes: ""},
{rel: "icon", href: "http://web-platform.test:8000/test6.ico", sizes: "any"},
{rel: "icon", href: "http://web-platform.test:8000/test6.ico", sizes: "32x32"},
];
var receivedEvents = [];
var iframe = document.createElement("iframe");
iframe.mozbrowser = "true";
iframe.src = "mozbrowsericonchange_event_test.html";
iframe.addEventListener("mozbrowsericonchange", t.step_func(e => {
receivedEvents.push({
rel: e.detail.rel,
href: e.detail.href,
sizes: e.detail.sizes,
});
if (receivedEvents.length == expectedEvents.length) {
for (var i = 0; i < expectedEvents.length; i++) {
var e1 = expectedEvents[i];
var e2 = receivedEvents[i];
assert_equals(e1.rel, e2.rel);
assert_equals(e1.href, e2.href);
assert_equals(e1.sizes, e2.sizes);
}
t.done();
}
}));
document.body.appendChild(iframe);
});
</script>
</body>

View file

@ -0,0 +1,22 @@
<html>
<head>
<link rel="icon" href="/test1.ico" sizes="any">
<link rel="icon" href="./test2.ico" sizes="16x16 24x24">
<link rel="shortcut icon" href="http://example.com/test3.ico">
<link rel="not-icon" href="xxx">
<link rel="icon no-href">
<link rel="apple-touch-icon" href="/test4.ico">
<script>
setTimeout(function() {
var link = document.createElement("link");
link.rel = "icon";
link.href = "/test5.ico"
document.head.appendChild(link);
link = document.querySelector('link[href="/test1.ico"]');
link.href = "/test6.ico";
setTimeout(() => link.setAttribute("sizes", "32x32"), 0);
}, 0);
</script>
</head>
<body>123</body>
</html>