browser/base/content/test/general/content_aboutAccounts.js

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

michael@0 1 /* This Source Code Form is subject to the terms of the Mozilla Public
michael@0 2 * License, v. 2.0. If a copy of the MPL was not distributed with this
michael@0 3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
michael@0 4
michael@0 5 // This file is loaded as a "content script" for browser_aboutAccounts tests
michael@0 6 "use strict";
michael@0 7
michael@0 8 addEventListener("load", function load(event) {
michael@0 9 if (event.target != content.document) {
michael@0 10 return;
michael@0 11 }
michael@0 12 // content.document.removeEventListener("load", load, true);
michael@0 13 sendAsyncMessage("test:document:load");
michael@0 14 }, true);
michael@0 15
michael@0 16 addEventListener("DOMContentLoaded", function domContentLoaded(event) {
michael@0 17 removeEventListener("DOMContentLoaded", domContentLoaded, true);
michael@0 18 let iframe = content.document.getElementById("remote");
michael@0 19 iframe.addEventListener("load", function iframeLoaded(event) {
michael@0 20 if (iframe.contentWindow.location.href == "about:blank" ||
michael@0 21 event.target != iframe) {
michael@0 22 return;
michael@0 23 }
michael@0 24 iframe.removeEventListener("load", iframeLoaded, true);
michael@0 25 sendAsyncMessage("test:iframe:load", {url: iframe.getAttribute("src")});
michael@0 26 }, true);
michael@0 27 }, true);
michael@0 28
michael@0 29 // Return the visibility state of a list of ids.
michael@0 30 addMessageListener("test:check-visibilities", function (message) {
michael@0 31 let result = {};
michael@0 32 for (let id of message.data.ids) {
michael@0 33 let elt = content.document.getElementById(id);
michael@0 34 if (elt) {
michael@0 35 let displayStyle = content.window.getComputedStyle(elt).display;
michael@0 36 if (displayStyle == 'none') {
michael@0 37 result[id] = false;
michael@0 38 } else if (displayStyle == 'block') {
michael@0 39 result[id] = true;
michael@0 40 } else {
michael@0 41 result[id] = "strange: " + displayStyle; // tests should fail!
michael@0 42 }
michael@0 43 } else {
michael@0 44 result[id] = "doesn't exist: " + id;
michael@0 45 }
michael@0 46 }
michael@0 47 sendAsyncMessage("test:check-visibilities-response", result);
michael@0 48 });

mercurial