[Browser API] implement mozbrowsericonchange event

This commit is contained in:
Paul Rouget 2015-11-12 12:10:22 +01:00
parent 27e104aa1a
commit 5263a4c4c9
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>