2007-12-23 12:41:53 -08:00
|
|
|
function test() {
|
|
|
|
waitForExplicitFinish();
|
|
|
|
|
|
|
|
// XXX This looks a bit odd, but is needed to avoid throwing when removing the
|
|
|
|
// event listeners below. See bug 310955.
|
2008-03-23 05:58:32 -07:00
|
|
|
document.getElementById("sidebar").addEventListener("load", delayedOpenUrl, true);
|
2007-12-23 12:41:53 -08:00
|
|
|
toggleSidebar("viewWebPanelsSidebar", true);
|
|
|
|
}
|
|
|
|
|
2008-03-23 05:58:32 -07:00
|
|
|
function delayedOpenUrl() {
|
2008-07-31 14:05:04 -07:00
|
|
|
ok(true, "Ran delayedOpenUrl");
|
2008-03-23 05:58:32 -07:00
|
|
|
setTimeout(openPanelUrl, 100);
|
|
|
|
}
|
|
|
|
|
2007-12-23 12:41:53 -08:00
|
|
|
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");
|
|
|
|
|
2008-03-23 05:58:32 -07:00
|
|
|
sidebar.removeEventListener("load", delayedOpenUrl, true);
|
2007-12-23 12:41:53 -08:00
|
|
|
// XXX See comment above
|
2008-03-23 05:58:32 -07:00
|
|
|
sidebar.contentDocument.addEventListener("load", delayedRunTest, true);
|
2011-02-08 07:02:20 -08:00
|
|
|
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">';
|
2007-12-23 12:41:53 -08:00
|
|
|
sidebar.contentWindow.loadWebPanel(url);
|
|
|
|
}
|
|
|
|
|
2008-03-23 05:58:32 -07:00
|
|
|
function delayedRunTest() {
|
2008-07-31 14:05:04 -07:00
|
|
|
ok(true, "Ran delayedRunTest");
|
2008-03-23 05:58:32 -07:00
|
|
|
setTimeout(runTest, 100);
|
|
|
|
}
|
|
|
|
|
2007-12-23 12:41:53 -08:00
|
|
|
function runTest(event) {
|
|
|
|
var sidebar = document.getElementById("sidebar");
|
2008-03-23 05:58:32 -07:00
|
|
|
sidebar.contentDocument.removeEventListener("load", delayedRunTest, true);
|
2007-12-23 12:41:53 -08:00
|
|
|
|
|
|
|
var browser = sidebar.contentDocument.getElementById("web-panels-browser");
|
|
|
|
var div = browser && browser.contentDocument.getElementById("test_bug409481");
|
|
|
|
ok(div && div.textContent == "Content!", "Sidebar content loaded");
|
|
|
|
|
2011-02-08 07:02:20 -08:00
|
|
|
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);
|
|
|
|
|
2007-12-23 12:41:53 -08:00
|
|
|
toggleSidebar("viewWebPanelsSidebar");
|
|
|
|
|
|
|
|
ok(document.getElementById("sidebar-box").hidden, "Sidebar successfully hidden");
|
|
|
|
|
|
|
|
finish();
|
|
|
|
}
|