Bug 1260528 - Tests for notifications that pass an iconUrl are causing leaks, r?kmag
MozReview-Commit-ID: KHdxEfc3OAG
--- a/toolkit/components/extensions/test/mochitest/test_ext_notifications.html
+++ b/toolkit/components/extensions/test/mochitest/test_ext_notifications.html
@@ -7,16 +7,22 @@
<script type="text/javascript" src="/tests/SimpleTest/ExtensionTestUtils.js"></script>
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
</head>
<body>
<script type="text/javascript">
"use strict";
+// A 1x1 PNG image.
+// Source: https://commons.wikimedia.org/wiki/File:1x1.png (Public Domain)
+let image = atob("iVBORw0KGgoAAAANSUhEUgAAAAEAAAABAQMAAAAl21bKAAAAA1BMVEUAA" +
+ "ACnej3aAAAAAXRSTlMAQObYZgAAAApJREFUCNdjYAAAAAIAAeIhvDMAAAAASUVORK5CYII=");
+const IMAGE_ARRAYBUFFER = Uint8Array.from(image, byte => byte.charCodeAt(0)).buffer;
+
add_task(function* test_notification() {
function backgroundScript() {
let opts = {
type: "basic",
title: "Testing Notification",
message: "Carry on",
};
@@ -136,16 +142,17 @@ add_task(function* test_notifications_em
yield extension.awaitFinish("getAll empty");
yield extension.unload();
});
add_task(function* test_notifications_populated_getAll() {
function backgroundScript() {
let opts = {
type: "basic",
+ iconUrl: "a.png",
title: "Testing Notification",
message: "Carry on",
};
browser.notifications.create("p1", opts).then(() => {
return browser.notifications.create("p2", opts);
}).then(() => {
return browser.notifications.getAll();
@@ -165,16 +172,19 @@ add_task(function* test_notifications_po
});
}
let extension = ExtensionTestUtils.loadExtension({
manifest: {
permissions: ["notifications"],
},
background: `(${backgroundScript})()`,
+ files: {
+ "a.png": IMAGE_ARRAYBUFFER,
+ },
});
yield extension.startup();
yield extension.awaitFinish("getAll populated");
yield extension.unload();
});
</script>