michael@0: /* Any copyright is dedicated to the Public Domain. michael@0: * http://creativecommons.org/publicdomain/zero/1.0/ */ michael@0: michael@0: function test() { michael@0: waitForExplicitFinish(); michael@0: michael@0: let tab = gBrowser.selectedTab = gBrowser.addTab(); michael@0: registerCleanupFunction(function () { michael@0: gBrowser.removeTab(tab); michael@0: }); michael@0: michael@0: let browser = tab.linkedBrowser; michael@0: browser.stop(); // stop the about:blank load michael@0: michael@0: let writeDomainURL = encodeURI("data:text/html,"); michael@0: let tests = [ michael@0: { michael@0: name: "view background image", michael@0: url: "http://mochi.test:8888/", michael@0: go: function (cb) { michael@0: let contentBody = browser.contentDocument.body; michael@0: contentBody.style.backgroundImage = "url('" + writeDomainURL + "')"; michael@0: doOnLoad(function () { michael@0: let domain = browser.contentDocument.body.textContent; michael@0: is(domain, "", "no domain was inherited for view background image"); michael@0: cb(); michael@0: }); michael@0: michael@0: let contextMenu = initContextMenu(contentBody); michael@0: contextMenu.viewBGImage(); michael@0: } michael@0: }, michael@0: { michael@0: name: "view image", michael@0: url: "http://mochi.test:8888/", michael@0: go: function (cb) { michael@0: doOnLoad(function () { michael@0: let domain = browser.contentDocument.body.textContent; michael@0: is(domain, "", "no domain was inherited for view image"); michael@0: cb(); michael@0: }); michael@0: michael@0: let doc = browser.contentDocument; michael@0: let img = doc.createElement("img"); michael@0: img.setAttribute("src", writeDomainURL); michael@0: doc.body.appendChild(img); michael@0: michael@0: let contextMenu = initContextMenu(img); michael@0: contextMenu.viewMedia(); michael@0: } michael@0: }, michael@0: { michael@0: name: "show only this frame", michael@0: url: "http://mochi.test:8888/", michael@0: go: function (cb) { michael@0: doOnLoad(function () { michael@0: let domain = browser.contentDocument.body.textContent; michael@0: is(domain, "", "no domain was inherited for 'show only this frame'"); michael@0: cb(); michael@0: }); michael@0: michael@0: let doc = browser.contentDocument; michael@0: let iframe = doc.createElement("iframe"); michael@0: iframe.setAttribute("src", writeDomainURL); michael@0: doc.body.appendChild(iframe); michael@0: michael@0: iframe.addEventListener("load", function onload() { michael@0: let contextMenu = initContextMenu(iframe.contentDocument.body); michael@0: contextMenu.showOnlyThisFrame(); michael@0: }, false); michael@0: } michael@0: } michael@0: ]; michael@0: michael@0: function doOnLoad(cb) { michael@0: browser.addEventListener("load", function onLoad(e) { michael@0: if (e.target != browser.contentDocument) michael@0: return; michael@0: browser.removeEventListener("load", onLoad, true); michael@0: cb(); michael@0: }, true); michael@0: } michael@0: michael@0: function doNext() { michael@0: let test = tests.shift(); michael@0: if (test) { michael@0: info("Running test: " + test.name); michael@0: doOnLoad(function () { michael@0: test.go(function () { michael@0: executeSoon(doNext); michael@0: }); michael@0: }); michael@0: browser.contentDocument.location = test.url; michael@0: } else { michael@0: executeSoon(finish); michael@0: } michael@0: } michael@0: michael@0: doNext(); michael@0: } michael@0: michael@0: function initContextMenu(aNode) { michael@0: document.popupNode = aNode; michael@0: let contentAreaContextMenu = document.getElementById("contentAreaContextMenu"); michael@0: let contextMenu = new nsContextMenu(contentAreaContextMenu); michael@0: return contextMenu; michael@0: }