diff options
author | Matt A. Tobin <mattatobin@localhost.localdomain> | 2018-02-02 04:16:08 -0500 |
---|---|---|
committer | Matt A. Tobin <mattatobin@localhost.localdomain> | 2018-02-02 04:16:08 -0500 |
commit | 5f8de423f190bbb79a62f804151bc24824fa32d8 (patch) | |
tree | 10027f336435511475e392454359edea8e25895d /toolkit/content/tests/browser/browser_bug1170531.js | |
parent | 49ee0794b5d912db1f95dce6eb52d781dc210db5 (diff) | |
download | UXP-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 'toolkit/content/tests/browser/browser_bug1170531.js')
-rw-r--r-- | toolkit/content/tests/browser/browser_bug1170531.js | 92 |
1 files changed, 92 insertions, 0 deletions
diff --git a/toolkit/content/tests/browser/browser_bug1170531.js b/toolkit/content/tests/browser/browser_bug1170531.js new file mode 100644 index 000000000..49df5661a --- /dev/null +++ b/toolkit/content/tests/browser/browser_bug1170531.js @@ -0,0 +1,92 @@ +// Test for bug 1170531 +// https://bugzilla.mozilla.org/show_bug.cgi?id=1170531 + +add_task(function* () { + // Get a bunch of DOM nodes + let winUtils = window.QueryInterface(Ci.nsIInterfaceRequestor). + getInterface(Ci.nsIDOMWindowUtils); + + let editMenu = document.getElementById("edit-menu"); + let menubar = editMenu.parentNode; + let menuPopup = editMenu.menupopup; + let editMenuIndex = -1; + for (let i = 0; i < menubar.children.length; i++) { + if (menubar.children[i] === editMenu) { + editMenuIndex = i; + break; + } + } + + let closeMenu = function(aCallback) { + if (OS.Constants.Sys.Name == "Darwin") { + executeSoon(aCallback); + return; + } + + menuPopup.addEventListener("popuphidden", function onPopupHidden() { + menuPopup.removeEventListener("popuphidden", onPopupHidden, false); + executeSoon(aCallback); + }, false); + + executeSoon(function() { + editMenu.open = false; + }); + }; + + let openMenu = function(aCallback) { + if (OS.Constants.Sys.Name == "Darwin") { + goUpdateGlobalEditMenuItems(); + // On OSX, we have a native menu, so it has to be updated. In single process browsers, + // this happens synchronously, but in e10s, we have to wait for the main thread + // to deal with it for us. 1 second should be plenty of time. + setTimeout(aCallback, 1000); + return; + } + + menuPopup.addEventListener("popupshown", function onPopupShown() { + menuPopup.removeEventListener("popupshown", onPopupShown, false); + executeSoon(aCallback); + }, false); + + executeSoon(function() { + editMenu.open = true; + }); + }; + + yield BrowserTestUtils.withNewTab({ gBrowser: gBrowser, url: "about:blank" }, function* (browser) { + let menu_cut_disabled, menu_copy_disabled; + + yield BrowserTestUtils.loadURI(browser, "data:text/html,<div>hello!</div>"); + yield BrowserTestUtils.browserLoaded(browser); + browser.focus(); + yield new Promise(resolve => waitForFocus(resolve, window)); + yield new Promise(openMenu); + menu_cut_disabled = menuPopup.querySelector("#menu_cut").getAttribute('disabled') == "true"; + is(menu_cut_disabled, false, "menu_cut should be enabled"); + menu_copy_disabled = menuPopup.querySelector("#menu_copy").getAttribute('disabled') == "true"; + is(menu_copy_disabled, false, "menu_copy should be enabled"); + yield new Promise(closeMenu); + + yield BrowserTestUtils.loadURI(browser, "data:text/html,<div contentEditable='true'>hello!</div>"); + yield BrowserTestUtils.browserLoaded(browser); + browser.focus(); + yield new Promise(resolve => waitForFocus(resolve, window)); + yield new Promise(openMenu); + menu_cut_disabled = menuPopup.querySelector("#menu_cut").getAttribute('disabled') == "true"; + is(menu_cut_disabled, false, "menu_cut should be enabled"); + menu_copy_disabled = menuPopup.querySelector("#menu_copy").getAttribute('disabled') == "true"; + is(menu_copy_disabled, false, "menu_copy should be enabled"); + yield new Promise(closeMenu); + + yield BrowserTestUtils.loadURI(browser, "about:preferences"); + yield BrowserTestUtils.browserLoaded(browser); + browser.focus(); + yield new Promise(resolve => waitForFocus(resolve, window)); + yield new Promise(openMenu); + menu_cut_disabled = menuPopup.querySelector("#menu_cut").getAttribute('disabled') == "true"; + is(menu_cut_disabled, true, "menu_cut should be disabled"); + menu_copy_disabled = menuPopup.querySelector("#menu_copy").getAttribute('disabled') == "true"; + is(menu_copy_disabled, true, "menu_copy should be disabled"); + yield new Promise(closeMenu); + }); +}); |