michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: // This file is loaded as a "content script" for browser_aboutAccounts tests michael@0: "use strict"; michael@0: michael@0: addEventListener("load", function load(event) { michael@0: if (event.target != content.document) { michael@0: return; michael@0: } michael@0: // content.document.removeEventListener("load", load, true); michael@0: sendAsyncMessage("test:document:load"); michael@0: }, true); michael@0: michael@0: addEventListener("DOMContentLoaded", function domContentLoaded(event) { michael@0: removeEventListener("DOMContentLoaded", domContentLoaded, true); michael@0: let iframe = content.document.getElementById("remote"); michael@0: iframe.addEventListener("load", function iframeLoaded(event) { michael@0: if (iframe.contentWindow.location.href == "about:blank" || michael@0: event.target != iframe) { michael@0: return; michael@0: } michael@0: iframe.removeEventListener("load", iframeLoaded, true); michael@0: sendAsyncMessage("test:iframe:load", {url: iframe.getAttribute("src")}); michael@0: }, true); michael@0: }, true); michael@0: michael@0: // Return the visibility state of a list of ids. michael@0: addMessageListener("test:check-visibilities", function (message) { michael@0: let result = {}; michael@0: for (let id of message.data.ids) { michael@0: let elt = content.document.getElementById(id); michael@0: if (elt) { michael@0: let displayStyle = content.window.getComputedStyle(elt).display; michael@0: if (displayStyle == 'none') { michael@0: result[id] = false; michael@0: } else if (displayStyle == 'block') { michael@0: result[id] = true; michael@0: } else { michael@0: result[id] = "strange: " + displayStyle; // tests should fail! michael@0: } michael@0: } else { michael@0: result[id] = "doesn't exist: " + id; michael@0: } michael@0: } michael@0: sendAsyncMessage("test:check-visibilities-response", result); michael@0: });