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