summaryrefslogtreecommitdiffstats
path: root/browser/base/content/test/general/browser_bug409481.js
diff options
context:
space:
mode:
authorMatt A. Tobin <mattatobin@localhost.localdomain>2018-02-02 04:16:08 -0500
committerMatt A. Tobin <mattatobin@localhost.localdomain>2018-02-02 04:16:08 -0500
commit5f8de423f190bbb79a62f804151bc24824fa32d8 (patch)
tree10027f336435511475e392454359edea8e25895d /browser/base/content/test/general/browser_bug409481.js
parent49ee0794b5d912db1f95dce6eb52d781dc210db5 (diff)
downloadUXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.gz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.lz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.xz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.zip
Add m-esr52 at 52.6.0
Diffstat (limited to 'browser/base/content/test/general/browser_bug409481.js')
-rw-r--r--browser/base/content/test/general/browser_bug409481.js83
1 files changed, 83 insertions, 0 deletions
diff --git a/browser/base/content/test/general/browser_bug409481.js b/browser/base/content/test/general/browser_bug409481.js
new file mode 100644
index 000000000..395ad93d4
--- /dev/null
+++ b/browser/base/content/test/general/browser_bug409481.js
@@ -0,0 +1,83 @@
+function test() {
+ waitForExplicitFinish();
+
+ // XXX This looks a bit odd, but is needed to avoid throwing when removing the
+ // event listeners below. See bug 310955.
+ document.getElementById("sidebar").addEventListener("load", delayedOpenUrl, true);
+ SidebarUI.show("viewWebPanelsSidebar");
+}
+
+function delayedOpenUrl() {
+ ok(true, "Ran delayedOpenUrl");
+ setTimeout(openPanelUrl, 100);
+}
+
+function openPanelUrl(event) {
+ ok(!document.getElementById("sidebar-box").hidden, "Sidebar showing");
+
+ var sidebar = document.getElementById("sidebar");
+ var root = sidebar.contentDocument.documentElement;
+ ok(root.nodeName != "parsererror", "Sidebar is well formed");
+
+ sidebar.removeEventListener("load", delayedOpenUrl, true);
+ // XXX See comment above
+ sidebar.contentDocument.addEventListener("load", delayedRunTest, true);
+ 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">';
+ sidebar.contentWindow.loadWebPanel(url);
+}
+
+function delayedRunTest() {
+ ok(true, "Ran delayedRunTest");
+ setTimeout(runTest, 100);
+}
+
+function runTest(event) {
+ var sidebar = document.getElementById("sidebar");
+ sidebar.contentDocument.removeEventListener("load", delayedRunTest, true);
+
+ var browser = sidebar.contentDocument.getElementById("web-panels-browser");
+ var div = browser && browser.contentDocument.getElementById("test_bug409481");
+ ok(div && div.textContent == "Content!", "Sidebar content loaded");
+
+ var link = browser && browser.contentDocument.getElementById("link");
+ sidebar.contentDocument.addEventListener("popupshown", contextMenuOpened, false);
+
+ EventUtils.synthesizeMouseAtCenter(link, { type: "contextmenu", button: 2 }, browser.contentWindow);
+}
+
+function contextMenuOpened()
+{
+ var sidebar = document.getElementById("sidebar");
+ sidebar.contentDocument.removeEventListener("popupshown", contextMenuOpened, false);
+
+ var copyLinkCommand = sidebar.contentDocument.getElementById("context-copylink");
+ copyLinkCommand.addEventListener("command", copyLinkCommandExecuted, false);
+ copyLinkCommand.doCommand();
+}
+
+function copyLinkCommandExecuted(event)
+{
+ event.target.removeEventListener("command", copyLinkCommandExecuted, false);
+
+ var sidebar = document.getElementById("sidebar");
+ var browser = sidebar.contentDocument.getElementById("web-panels-browser");
+ var textbox = browser && browser.contentDocument.getElementById("textbox");
+ textbox.focus();
+ document.commandDispatcher.getControllerForCommand("cmd_paste").doCommand("cmd_paste");
+ is(textbox.value, "http://www.example.com/ctest", "copy link command");
+
+ sidebar.contentDocument.addEventListener("popuphidden", contextMenuClosed, false);
+ event.target.parentNode.hidePopup();
+}
+
+function contextMenuClosed()
+{
+ var sidebar = document.getElementById("sidebar");
+ sidebar.contentDocument.removeEventListener("popuphidden", contextMenuClosed, false);
+
+ SidebarUI.hide();
+
+ ok(document.getElementById("sidebar-box").hidden, "Sidebar successfully hidden");
+
+ finish();
+}