1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/browser/base/content/test/general/browser_bug734076.js Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,107 @@ 1.4 +/* Any copyright is dedicated to the Public Domain. 1.5 + * http://creativecommons.org/publicdomain/zero/1.0/ */ 1.6 + 1.7 +function test() { 1.8 + waitForExplicitFinish(); 1.9 + 1.10 + let tab = gBrowser.selectedTab = gBrowser.addTab(); 1.11 + registerCleanupFunction(function () { 1.12 + gBrowser.removeTab(tab); 1.13 + }); 1.14 + 1.15 + let browser = tab.linkedBrowser; 1.16 + browser.stop(); // stop the about:blank load 1.17 + 1.18 + let writeDomainURL = encodeURI("data:text/html,<script>document.write(document.domain);</script>"); 1.19 + let tests = [ 1.20 + { 1.21 + name: "view background image", 1.22 + url: "http://mochi.test:8888/", 1.23 + go: function (cb) { 1.24 + let contentBody = browser.contentDocument.body; 1.25 + contentBody.style.backgroundImage = "url('" + writeDomainURL + "')"; 1.26 + doOnLoad(function () { 1.27 + let domain = browser.contentDocument.body.textContent; 1.28 + is(domain, "", "no domain was inherited for view background image"); 1.29 + cb(); 1.30 + }); 1.31 + 1.32 + let contextMenu = initContextMenu(contentBody); 1.33 + contextMenu.viewBGImage(); 1.34 + } 1.35 + }, 1.36 + { 1.37 + name: "view image", 1.38 + url: "http://mochi.test:8888/", 1.39 + go: function (cb) { 1.40 + doOnLoad(function () { 1.41 + let domain = browser.contentDocument.body.textContent; 1.42 + is(domain, "", "no domain was inherited for view image"); 1.43 + cb(); 1.44 + }); 1.45 + 1.46 + let doc = browser.contentDocument; 1.47 + let img = doc.createElement("img"); 1.48 + img.setAttribute("src", writeDomainURL); 1.49 + doc.body.appendChild(img); 1.50 + 1.51 + let contextMenu = initContextMenu(img); 1.52 + contextMenu.viewMedia(); 1.53 + } 1.54 + }, 1.55 + { 1.56 + name: "show only this frame", 1.57 + url: "http://mochi.test:8888/", 1.58 + go: function (cb) { 1.59 + doOnLoad(function () { 1.60 + let domain = browser.contentDocument.body.textContent; 1.61 + is(domain, "", "no domain was inherited for 'show only this frame'"); 1.62 + cb(); 1.63 + }); 1.64 + 1.65 + let doc = browser.contentDocument; 1.66 + let iframe = doc.createElement("iframe"); 1.67 + iframe.setAttribute("src", writeDomainURL); 1.68 + doc.body.appendChild(iframe); 1.69 + 1.70 + iframe.addEventListener("load", function onload() { 1.71 + let contextMenu = initContextMenu(iframe.contentDocument.body); 1.72 + contextMenu.showOnlyThisFrame(); 1.73 + }, false); 1.74 + } 1.75 + } 1.76 + ]; 1.77 + 1.78 + function doOnLoad(cb) { 1.79 + browser.addEventListener("load", function onLoad(e) { 1.80 + if (e.target != browser.contentDocument) 1.81 + return; 1.82 + browser.removeEventListener("load", onLoad, true); 1.83 + cb(); 1.84 + }, true); 1.85 + } 1.86 + 1.87 + function doNext() { 1.88 + let test = tests.shift(); 1.89 + if (test) { 1.90 + info("Running test: " + test.name); 1.91 + doOnLoad(function () { 1.92 + test.go(function () { 1.93 + executeSoon(doNext); 1.94 + }); 1.95 + }); 1.96 + browser.contentDocument.location = test.url; 1.97 + } else { 1.98 + executeSoon(finish); 1.99 + } 1.100 + } 1.101 + 1.102 + doNext(); 1.103 +} 1.104 + 1.105 +function initContextMenu(aNode) { 1.106 + document.popupNode = aNode; 1.107 + let contentAreaContextMenu = document.getElementById("contentAreaContextMenu"); 1.108 + let contextMenu = new nsContextMenu(contentAreaContextMenu); 1.109 + return contextMenu; 1.110 +}