Wed, 31 Dec 2014 06:09:35 +0100
Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.
1 /* Any copyright is dedicated to the Public Domain.
2 * http://creativecommons.org/publicdomain/zero/1.0/ */
4 function test() {
5 waitForExplicitFinish();
7 let tab = gBrowser.selectedTab = gBrowser.addTab();
8 registerCleanupFunction(function () {
9 gBrowser.removeTab(tab);
10 });
12 let browser = tab.linkedBrowser;
13 browser.stop(); // stop the about:blank load
15 let writeDomainURL = encodeURI("data:text/html,<script>document.write(document.domain);</script>");
16 let tests = [
17 {
18 name: "view background image",
19 url: "http://mochi.test:8888/",
20 go: function (cb) {
21 let contentBody = browser.contentDocument.body;
22 contentBody.style.backgroundImage = "url('" + writeDomainURL + "')";
23 doOnLoad(function () {
24 let domain = browser.contentDocument.body.textContent;
25 is(domain, "", "no domain was inherited for view background image");
26 cb();
27 });
29 let contextMenu = initContextMenu(contentBody);
30 contextMenu.viewBGImage();
31 }
32 },
33 {
34 name: "view image",
35 url: "http://mochi.test:8888/",
36 go: function (cb) {
37 doOnLoad(function () {
38 let domain = browser.contentDocument.body.textContent;
39 is(domain, "", "no domain was inherited for view image");
40 cb();
41 });
43 let doc = browser.contentDocument;
44 let img = doc.createElement("img");
45 img.setAttribute("src", writeDomainURL);
46 doc.body.appendChild(img);
48 let contextMenu = initContextMenu(img);
49 contextMenu.viewMedia();
50 }
51 },
52 {
53 name: "show only this frame",
54 url: "http://mochi.test:8888/",
55 go: function (cb) {
56 doOnLoad(function () {
57 let domain = browser.contentDocument.body.textContent;
58 is(domain, "", "no domain was inherited for 'show only this frame'");
59 cb();
60 });
62 let doc = browser.contentDocument;
63 let iframe = doc.createElement("iframe");
64 iframe.setAttribute("src", writeDomainURL);
65 doc.body.appendChild(iframe);
67 iframe.addEventListener("load", function onload() {
68 let contextMenu = initContextMenu(iframe.contentDocument.body);
69 contextMenu.showOnlyThisFrame();
70 }, false);
71 }
72 }
73 ];
75 function doOnLoad(cb) {
76 browser.addEventListener("load", function onLoad(e) {
77 if (e.target != browser.contentDocument)
78 return;
79 browser.removeEventListener("load", onLoad, true);
80 cb();
81 }, true);
82 }
84 function doNext() {
85 let test = tests.shift();
86 if (test) {
87 info("Running test: " + test.name);
88 doOnLoad(function () {
89 test.go(function () {
90 executeSoon(doNext);
91 });
92 });
93 browser.contentDocument.location = test.url;
94 } else {
95 executeSoon(finish);
96 }
97 }
99 doNext();
100 }
102 function initContextMenu(aNode) {
103 document.popupNode = aNode;
104 let contentAreaContextMenu = document.getElementById("contentAreaContextMenu");
105 let contextMenu = new nsContextMenu(contentAreaContextMenu);
106 return contextMenu;
107 }