mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-12-03 18:47:53 +00:00
Bug 1199180 - Use proper EventUtils lib to fix intermittent test failure. r=pbrosset
This commit is contained in:
parent
bd11786162
commit
521114354e
@ -23,6 +23,7 @@ support-files =
|
||||
doc_markup_toggle.html
|
||||
doc_markup_tooltip.png
|
||||
doc_markup_xul.xul
|
||||
frame-script-utils.js
|
||||
head.js
|
||||
helper_attributes_test_runner.js
|
||||
helper_events_test_runner.js
|
||||
|
@ -45,10 +45,28 @@ function assertNodeSelected(inspector, tagName) {
|
||||
}
|
||||
|
||||
function* selectWithBrowserMenu(inspector) {
|
||||
yield BrowserTestUtils.synthesizeMouseAtCenter("div", {
|
||||
type: "contextmenu",
|
||||
button: 2
|
||||
}, gBrowser.selectedBrowser);
|
||||
// This test can't use BrowserTestUtils.synthesizeMouseAtCenter()
|
||||
// method (see below) since it causes intermittent test failures.
|
||||
// So, we are introducing a new "Test:MarkupView:SynthesizeMouse" event
|
||||
// that is handled in the content scope. The main difference between
|
||||
// this new event and BrowserTestUtils library is EventUtils library.
|
||||
// While BrowserTestUtils is using:
|
||||
// chrome://mochikit/content/tests/SimpleTest/EventUtils.js
|
||||
// (see: AsyncUtilsContent.js)
|
||||
// ... this test requires:
|
||||
// chrome://marionette/content/EventUtils.js
|
||||
// (see markupview/test/frame-script-utils.js)
|
||||
// See also: https://bugzilla.mozilla.org/show_bug.cgi?id=1199180
|
||||
yield executeInContent("Test:MarkupView:SynthesizeMouse", {
|
||||
center: true,
|
||||
selector: "div",
|
||||
options: {type: "contextmenu", button: 2}
|
||||
});
|
||||
|
||||
//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,
|
||||
@ -70,9 +88,18 @@ function* selectWithBrowserMenu(inspector) {
|
||||
|
||||
function* selectWithElementPicker(inspector) {
|
||||
yield inspector.toolbox.highlighterUtils.startPicker();
|
||||
yield BrowserTestUtils.synthesizeMouseAtCenter("div", {
|
||||
type: "mousemove",
|
||||
}, gBrowser.selectedBrowser);
|
||||
|
||||
yield executeInContent("Test:MarkupView:SynthesizeMouse", {
|
||||
center: true,
|
||||
selector: "div",
|
||||
options: {type: "mousemove"}
|
||||
});
|
||||
|
||||
// Read comment in selectWithBrowserMenu() method.
|
||||
//yield BrowserTestUtils.synthesizeMouseAtCenter("div", {
|
||||
// type: "mousemove",
|
||||
//}, gBrowser.selectedBrowser);
|
||||
|
||||
executeInContent("Test:SynthesizeKey", {
|
||||
key: "VK_RETURN",
|
||||
options: {}
|
||||
|
46
browser/devtools/markupview/test/frame-script-utils.js
Normal file
46
browser/devtools/markupview/test/frame-script-utils.js
Normal file
@ -0,0 +1,46 @@
|
||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
"use strict";
|
||||
|
||||
const {classes: Cc, interfaces: Ci} = Components;
|
||||
const subScriptLoader = Cc["@mozilla.org/moz/jssubscript-loader;1"]
|
||||
.getService(Ci.mozIJSSubScriptLoader);
|
||||
let EventUtils = {};
|
||||
subScriptLoader.loadSubScript("chrome://marionette/content/EventUtils.js", EventUtils);
|
||||
|
||||
/**
|
||||
* Synthesize a mouse event on an element. This handler doesn't send a message
|
||||
* back. Consumers should listen to specific events on the inspector/highlighter
|
||||
* to know when the event got synthesized.
|
||||
* @param {Object} msg The msg.data part expects the following properties:
|
||||
* - {Number} x
|
||||
* - {Number} y
|
||||
* - {Boolean} center If set to true, x/y will be ignored and
|
||||
* synthesizeMouseAtCenter will be used instead
|
||||
* - {Object} options Other event options
|
||||
* - {String} selector An optional selector that will be used to find the node to
|
||||
* synthesize the event on, if msg.objects doesn't contain the CPOW.
|
||||
* The msg.objects part should be the element.
|
||||
* @param {Object} data Event detail properties:
|
||||
*/
|
||||
addMessageListener("Test:MarkupView:SynthesizeMouse", function(msg) {
|
||||
let {x, y, center, options, selector} = msg.data;
|
||||
let {node} = msg.objects;
|
||||
|
||||
if (!node && selector) {
|
||||
node = content.document.querySelector(selector);
|
||||
}
|
||||
|
||||
if (center) {
|
||||
EventUtils.synthesizeMouseAtCenter(node, options, node.ownerDocument.defaultView);
|
||||
} else {
|
||||
EventUtils.synthesizeMouse(node, x, y, options, node.ownerDocument.defaultView);
|
||||
}
|
||||
|
||||
// Most consumers won't need to listen to this message, unless they want to
|
||||
// wait for the mouse event to be synthesized and don't have another event
|
||||
// to listen to instead.
|
||||
sendAsyncMessage("Test:MarkupView:SynthesizeMouse");
|
||||
});
|
@ -51,6 +51,7 @@ registerCleanupFunction(function*() {
|
||||
const TEST_URL_ROOT = "http://mochi.test:8888/browser/browser/devtools/markupview/test/";
|
||||
const CHROME_BASE = "chrome://mochitests/content/browser/browser/devtools/markupview/test/";
|
||||
const COMMON_FRAME_SCRIPT_URL = "chrome://browser/content/devtools/frame-script-utils.js";
|
||||
const MARKUPVIEW_FRAME_SCRIPT_URL = CHROME_BASE + "frame-script-utils.js";
|
||||
|
||||
/**
|
||||
* Add a new test tab in the browser and load the given url.
|
||||
@ -71,6 +72,7 @@ function addTab(url) {
|
||||
|
||||
info("Loading the helper frame script " + COMMON_FRAME_SCRIPT_URL);
|
||||
linkedBrowser.messageManager.loadFrameScript(COMMON_FRAME_SCRIPT_URL, false);
|
||||
linkedBrowser.messageManager.loadFrameScript(MARKUPVIEW_FRAME_SCRIPT_URL, false);
|
||||
|
||||
linkedBrowser.addEventListener("load", function onload() {
|
||||
linkedBrowser.removeEventListener("load", onload, true);
|
||||
|
Loading…
Reference in New Issue
Block a user