bug 1312161 - Ensure cleanup when match_about_blank test fails, r?kmag
MozReview-Commit-ID: HVy7Lm3CM6H
--- a/toolkit/components/extensions/test/mochitest/test_ext_contentscript_about_blank.html
+++ b/toolkit/components/extensions/test/mochitest/test_ext_contentscript_about_blank.html
@@ -64,23 +64,31 @@ add_task(function* test_contentscript_ab
browser.test.sendMessage(`${script}:${kind}`);
});
}
const PATH = "tests/toolkit/components/extensions/test/mochitest/file_with_about_blank.html";
const extension = ExtensionTestUtils.loadExtension({manifest, files, background});
yield extension.startup();
+ let win;
+ SimpleTest.registerCleanupFunction(() => {
+ if (win && !win.closed) {
+ win.close();
+ }
+ return extension.unload();
+ });
+
let count = 0;
extension.onMessage("script", script => {
info(`script ran: ${script}`);
count++;
});
- let win = window.open("http://example.com/" + PATH);
+ win = window.open("http://example.com/" + PATH);
yield Promise.all([
extension.awaitMessage("all:top"),
extension.awaitMessage("all:about:blank"),
extension.awaitMessage("all:about:srcdoc"),
]);
is(count, 3, "exactly 3 scripts ran");
win.close();
@@ -103,15 +111,13 @@ add_task(function* test_contentscript_ab
let a_b = win.document.getElementById("a_b");
style = a_b.contentWindow.getComputedStyle(a_b.contentDocument.body);
is(style.color, "rgb(255, 0, 0)", "about:blank iframe text color is red");
is(style.backgroundColor, "transparent", "about:blank iframe background is transparent");
is(style.textAlign, "right", "about:blank text is right-aligned");
is(count, 10, "exactly 7 more scripts ran");
win.close();
-
- yield extension.unload();
});
</script>
</body>
</html>