diff options
author | Matt A. Tobin <email@mattatobin.com> | 2020-02-25 15:07:00 -0500 |
---|---|---|
committer | wolfbeast <mcwerewolf@wolfbeast.com> | 2020-04-14 12:55:19 +0200 |
commit | eb70e6e3d0bff11c25f14b1196025791bf2308fb (patch) | |
tree | 5ef4ce17db83c74d7b05ec12c8f59e095a6dd5bd /toolkit/components/viewsource/test/browser/browser_contextmenu.js | |
parent | 32ead795290b3399d56b4708fc75b77d296f6a1a (diff) | |
download | UXP-eb70e6e3d0bff11c25f14b1196025791bf2308fb.tar UXP-eb70e6e3d0bff11c25f14b1196025791bf2308fb.tar.gz UXP-eb70e6e3d0bff11c25f14b1196025791bf2308fb.tar.lz UXP-eb70e6e3d0bff11c25f14b1196025791bf2308fb.tar.xz UXP-eb70e6e3d0bff11c25f14b1196025791bf2308fb.zip |
Issue #439 - Remove tests from toolkit/
Diffstat (limited to 'toolkit/components/viewsource/test/browser/browser_contextmenu.js')
-rw-r--r-- | toolkit/components/viewsource/test/browser/browser_contextmenu.js | 107 |
1 files changed, 0 insertions, 107 deletions
diff --git a/toolkit/components/viewsource/test/browser/browser_contextmenu.js b/toolkit/components/viewsource/test/browser/browser_contextmenu.js deleted file mode 100644 index 72b8a40be..000000000 --- a/toolkit/components/viewsource/test/browser/browser_contextmenu.js +++ /dev/null @@ -1,107 +0,0 @@ -/* Any copyright is dedicated to the Public Domain. - * http://creativecommons.org/publicdomain/zero/1.0/ - */ - -var source = "data:text/html,text<link%20href='http://example.com/'%20/>more%20text<a%20href='mailto:abc@def.ghi'>email</a>"; -var gViewSourceWindow, gContextMenu, gCopyLinkMenuItem, gCopyEmailMenuItem; - -var expectedData = []; - -add_task(function *() { - // Full source in view source window - let newWindow = yield loadViewSourceWindow(source); - yield SimpleTest.promiseFocus(newWindow); - - yield* onViewSourceWindowOpen(newWindow, false); - - let contextMenu = gViewSourceWindow.document.getElementById("viewSourceContextMenu"); - - for (let test of expectedData) { - yield* checkMenuItems(contextMenu, false, test[0], test[1], test[2], test[3]); - } - - yield new Promise(resolve => { - closeViewSourceWindow(newWindow, resolve); - }); - - // Selection source in view source tab - expectedData = []; - let newTab = yield openDocumentSelect(source, "body"); - yield* onViewSourceWindowOpen(window, true); - - contextMenu = document.getElementById("contentAreaContextMenu"); - - for (let test of expectedData) { - yield* checkMenuItems(contextMenu, true, test[0], test[1], test[2], test[3]); - } - - gBrowser.removeTab(newTab); - - // Selection source in view source window - yield pushPrefs(["view_source.tab", false]); - - expectedData = []; - newWindow = yield openDocumentSelect(source, "body"); - yield SimpleTest.promiseFocus(newWindow); - - yield* onViewSourceWindowOpen(newWindow, false); - - contextMenu = newWindow.document.getElementById("viewSourceContextMenu"); - - for (let test of expectedData) { - yield* checkMenuItems(contextMenu, false, test[0], test[1], test[2], test[3]); - } - - yield new Promise(resolve => { - closeViewSourceWindow(newWindow, resolve); - }); -}); - -function* onViewSourceWindowOpen(aWindow, aIsTab) { - gViewSourceWindow = aWindow; - - gCopyLinkMenuItem = aWindow.document.getElementById(aIsTab ? "context-copylink" : "context-copyLink"); - gCopyEmailMenuItem = aWindow.document.getElementById(aIsTab ? "context-copyemail" : "context-copyEmail"); - - let browser = aIsTab ? gBrowser.selectedBrowser : gViewSourceWindow.gBrowser; - yield ContentTask.spawn(browser, null, function* (arg) { - let tags = content.document.querySelectorAll("a[href]"); - Assert.equal(tags[0].href, "view-source:http://example.com/", "Link has correct href"); - Assert.equal(tags[1].href, "mailto:abc@def.ghi", "Link has correct href"); - }); - - expectedData.push(["a[href]", true, false, "http://example.com/"]); - expectedData.push(["a[href^=mailto]", false, true, "abc@def.ghi"]); - expectedData.push(["span", false, false, null]); -} - -function* checkMenuItems(contextMenu, isTab, selector, copyLinkExpected, copyEmailExpected, expectedClipboardContent) { - - let browser = isTab ? gBrowser.selectedBrowser : gViewSourceWindow.gBrowser; - yield ContentTask.spawn(browser, { selector: selector }, function* (arg) { - content.document.querySelector(arg.selector).scrollIntoView(); - }); - - let popupShownPromise = BrowserTestUtils.waitForEvent(contextMenu, "popupshown"); - yield BrowserTestUtils.synthesizeMouseAtCenter(selector, - { type: "contextmenu", button: 2}, browser); - yield popupShownPromise; - - is(gCopyLinkMenuItem.hidden, !copyLinkExpected, "Copy link menuitem is " + (copyLinkExpected ? "not hidden" : "hidden")); - is(gCopyEmailMenuItem.hidden, !copyEmailExpected, "Copy email menuitem is " + (copyEmailExpected ? "not hidden" : "hidden")); - - if (copyLinkExpected || copyEmailExpected) { - yield new Promise((resolve, reject) => { - waitForClipboard(expectedClipboardContent, function() { - if (copyLinkExpected) - gCopyLinkMenuItem.click(); - else - gCopyEmailMenuItem.click(); - }, resolve, reject); - }); - } - - let popupHiddenPromise = BrowserTestUtils.waitForEvent(contextMenu, "popuphidden"); - contextMenu.hidePopup(); - yield popupHiddenPromise; -} |