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