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 | function test() { |
michael@0 | 2 | waitForExplicitFinish(); |
michael@0 | 3 | |
michael@0 | 4 | // XXX This looks a bit odd, but is needed to avoid throwing when removing the |
michael@0 | 5 | // event listeners below. See bug 310955. |
michael@0 | 6 | document.getElementById("sidebar").addEventListener("load", delayedOpenUrl, true); |
michael@0 | 7 | toggleSidebar("viewWebPanelsSidebar", true); |
michael@0 | 8 | } |
michael@0 | 9 | |
michael@0 | 10 | function delayedOpenUrl() { |
michael@0 | 11 | ok(true, "Ran delayedOpenUrl"); |
michael@0 | 12 | setTimeout(openPanelUrl, 100); |
michael@0 | 13 | } |
michael@0 | 14 | |
michael@0 | 15 | function openPanelUrl(event) { |
michael@0 | 16 | ok(!document.getElementById("sidebar-box").hidden, "Sidebar showing"); |
michael@0 | 17 | |
michael@0 | 18 | var sidebar = document.getElementById("sidebar"); |
michael@0 | 19 | var root = sidebar.contentDocument.documentElement; |
michael@0 | 20 | ok(root.nodeName != "parsererror", "Sidebar is well formed"); |
michael@0 | 21 | |
michael@0 | 22 | sidebar.removeEventListener("load", delayedOpenUrl, true); |
michael@0 | 23 | // XXX See comment above |
michael@0 | 24 | sidebar.contentDocument.addEventListener("load", delayedRunTest, true); |
michael@0 | 25 | var url = 'data:text/html,<div%20id="test_bug409481">Content!</div><a id="link" href="http://www.example.com/ctest">Link</a><input id="textbox">'; |
michael@0 | 26 | sidebar.contentWindow.loadWebPanel(url); |
michael@0 | 27 | } |
michael@0 | 28 | |
michael@0 | 29 | function delayedRunTest() { |
michael@0 | 30 | ok(true, "Ran delayedRunTest"); |
michael@0 | 31 | setTimeout(runTest, 100); |
michael@0 | 32 | } |
michael@0 | 33 | |
michael@0 | 34 | function runTest(event) { |
michael@0 | 35 | var sidebar = document.getElementById("sidebar"); |
michael@0 | 36 | sidebar.contentDocument.removeEventListener("load", delayedRunTest, true); |
michael@0 | 37 | |
michael@0 | 38 | var browser = sidebar.contentDocument.getElementById("web-panels-browser"); |
michael@0 | 39 | var div = browser && browser.contentDocument.getElementById("test_bug409481"); |
michael@0 | 40 | ok(div && div.textContent == "Content!", "Sidebar content loaded"); |
michael@0 | 41 | |
michael@0 | 42 | var link = browser && browser.contentDocument.getElementById("link"); |
michael@0 | 43 | sidebar.contentDocument.addEventListener("popupshown", contextMenuOpened, false); |
michael@0 | 44 | |
michael@0 | 45 | EventUtils.synthesizeMouseAtCenter(link, { type: "contextmenu", button: 2 }, browser.contentWindow); |
michael@0 | 46 | } |
michael@0 | 47 | |
michael@0 | 48 | function contextMenuOpened() |
michael@0 | 49 | { |
michael@0 | 50 | var sidebar = document.getElementById("sidebar"); |
michael@0 | 51 | sidebar.contentDocument.removeEventListener("popupshown", contextMenuOpened, false); |
michael@0 | 52 | |
michael@0 | 53 | var copyLinkCommand = sidebar.contentDocument.getElementById("context-copylink"); |
michael@0 | 54 | copyLinkCommand.addEventListener("command", copyLinkCommandExecuted, false); |
michael@0 | 55 | copyLinkCommand.doCommand(); |
michael@0 | 56 | } |
michael@0 | 57 | |
michael@0 | 58 | function copyLinkCommandExecuted(event) |
michael@0 | 59 | { |
michael@0 | 60 | event.target.removeEventListener("command", copyLinkCommandExecuted, false); |
michael@0 | 61 | |
michael@0 | 62 | var sidebar = document.getElementById("sidebar"); |
michael@0 | 63 | var browser = sidebar.contentDocument.getElementById("web-panels-browser"); |
michael@0 | 64 | var textbox = browser && browser.contentDocument.getElementById("textbox"); |
michael@0 | 65 | textbox.focus(); |
michael@0 | 66 | document.commandDispatcher.getControllerForCommand("cmd_paste").doCommand("cmd_paste"); |
michael@0 | 67 | is(textbox.value, "http://www.example.com/ctest", "copy link command"); |
michael@0 | 68 | |
michael@0 | 69 | sidebar.contentDocument.addEventListener("popuphidden", contextMenuClosed, false); |
michael@0 | 70 | event.target.parentNode.hidePopup(); |
michael@0 | 71 | } |
michael@0 | 72 | |
michael@0 | 73 | function contextMenuClosed() |
michael@0 | 74 | { |
michael@0 | 75 | var sidebar = document.getElementById("sidebar"); |
michael@0 | 76 | sidebar.contentDocument.removeEventListener("popuphidden", contextMenuClosed, false); |
michael@0 | 77 | |
michael@0 | 78 | toggleSidebar("viewWebPanelsSidebar"); |
michael@0 | 79 | |
michael@0 | 80 | ok(document.getElementById("sidebar-box").hidden, "Sidebar successfully hidden"); |
michael@0 | 81 | |
michael@0 | 82 | finish(); |
michael@0 | 83 | } |