Bug 1233497 - Avoid unsafe CPOWs in devtools tests. r=jryans

This commit is contained in:
Mike Conley 2016-01-07 11:54:18 -05:00
parent cedcf91446
commit 005a054df5
2 changed files with 14 additions and 22 deletions

View File

@ -48,27 +48,24 @@ function selectPreviousNodeWithArrowUp(inspector) {
}
function* selectWithBrowserMenu(inspector) {
let contentAreaContextMenu = document.querySelector("#contentAreaContextMenu");
let contextOpened = once(contentAreaContextMenu, "popupshown");
yield BrowserTestUtils.synthesizeMouseAtCenter("div", {
type: "contextmenu",
button: 2
}, gBrowser.selectedBrowser);
// nsContextMenu also requires the popupNode to be set, but we can't set it to
// node under e10s as it's a CPOW, not a DOM node. But under e10s,
// nsContextMenu won't use the property anyway, so just try/catching is ok.
try {
document.popupNode = getNode("div");
} catch (e) {}
yield contextOpened;
let contentAreaContextMenu = document.querySelector("#contentAreaContextMenu");
let contextMenu = new nsContextMenu(contentAreaContextMenu);
yield contextMenu.inspectNode();
yield gContextMenu.inspectNode();
let contextClosed = once(contentAreaContextMenu, "popuphidden");
contentAreaContextMenu.hidden = true;
contentAreaContextMenu.hidePopup();
contextMenu.hiding();
yield inspector.once("inspector-updated");
yield contextClosed;
}
function* selectWithElementPicker(inspector, testActor) {

View File

@ -117,29 +117,24 @@ function* testBreadcrumbs(selector, inspector) {
function* clickOnInspectMenuItem(testActor, selector) {
info("Showing the contextual menu on node " + selector);
let contentAreaContextMenu = document.querySelector("#contentAreaContextMenu");
let contextOpened = once(contentAreaContextMenu, "popupshown");
yield testActor.synthesizeMouse({
selector: selector,
center: true,
options: {type: "contextmenu", button: 2}
});
// nsContextMenu also requires the popupNode to be set, but we can't set it to
// node under e10s as it's a CPOW, not a DOM node. But under e10s,
// nsContextMenu won't use the property anyway, so just try/catching is ok.
try {
document.popupNode = content.document.querySelector(selector);
} catch (e) {}
let contentAreaContextMenu = document.querySelector("#contentAreaContextMenu");
let contextMenu = new nsContextMenu(contentAreaContextMenu);
yield contextOpened;
info("Triggering inspect action and hiding the menu.");
yield contextMenu.inspectNode();
yield gContextMenu.inspectNode();
contentAreaContextMenu.hidden = true;
let contextClosed = once(contentAreaContextMenu, "popuphidden");
contentAreaContextMenu.hidePopup();
contextMenu.hiding();
info("Waiting for inspector to update.");
yield getActiveInspector().once("inspector-updated");
yield contextClosed;
}