Bug 1532584 - Test event-collector.js with chrome enabled r=ochameau

Differential Revision: https://phabricator.services.mozilla.com/D22076

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Michael Ratcliffe 2019-03-07 16:01:28 +00:00
Родитель 06e6e0dbbf
Коммит 9fd7fbf0f5
4 изменённых файлов: 55 добавлений и 59 удалений

Просмотреть файл

@ -5,9 +5,8 @@
"use strict";
// Test that markup view event bubbles are hidden for <video> tags in the
// content process when devtools.chrome.enabled=false.
// <video> tags have 22 chrome listeners.
// Test that markup view chrome event bubbles are hidden when
// devtools.chrome.enabled = false.
const TEST_URL = URL_ROOT + "doc_markup_events_chrome_listeners.html";
@ -15,12 +14,27 @@ loadHelperScript("helper_events_test_runner.js");
const TEST_DATA = [
{
selector: "video",
selector: "div",
expected: [ ],
},
];
add_task(async function() {
await pushPref("devtools.chrome.enabled", false);
await runEventPopupTests(TEST_URL, TEST_DATA);
const {tab, inspector, testActor} = await openInspectorForURL(TEST_URL);
const browser = tab.linkedBrowser;
const mm = browser.messageManager;
await mm.loadFrameScript(
`data:,const div = content.document.querySelector("div");` +
`div.addEventListener("click", () => {` +
` /* Do nothing */` +
`});`, false);
await inspector.markup.expandAll();
for (const test of TEST_DATA) {
await checkEventsForNode(test, inspector, testActor);
}
});

Просмотреть файл

@ -5,8 +5,8 @@
"use strict";
// Test that markup view event bubbles are shown for <video> tags in the
// content process when devtools.chrome.enabled=true.
// Test that markup view chrome event bubbles are shown when
// devtools.chrome.enabled = true.
const TEST_URL = URL_ROOT + "doc_markup_events_chrome_listeners.html";
@ -14,61 +14,38 @@ loadHelperScript("helper_events_test_runner.js");
const TEST_DATA = [
{
selector: "video",
selector: "div",
expected: [
createEvent("canplay"),
createEvent("canplaythrough"),
createEvent("emptied"),
createEvent("ended"),
createEvent("error"),
createEvent("keypress"),
createEvent("loadeddata"),
createEvent("loadedmetadata"),
createEvent("loadstart"),
createEvent("mozvideoonlyseekbegin"),
createEvent("mozvideoonlyseekcompleted"),
createEvent("pause"),
createEvent("play"),
createEvent("playing"),
createEvent("progress"),
createEvent("seeked"),
createEvent("seeking"),
createEvent("stalled"),
createEvent("suspend"),
createEvent("timeupdate"),
createEvent("volumechange"),
createEvent("waiting"),
{
type: "click",
filename: `data:,const div = content.document.querySelector("div");` +
`div.addEventListener("click", () => { /* Do nothing */});:1`,
attributes: [
"Bubbling",
"DOM2",
],
handler: `() => { /* Do nothing */ }`,
},
],
},
];
function createEvent(type) {
return {
type: type,
filename: "chrome://global/content/elements/videocontrols.js:437",
attributes: [
"Capturing",
"DOM2",
],
handler: `
${type === "play" ? "function" : "handleEvent"}(aEvent) {
if (!aEvent.isTrusted) {
this.log("Drop untrusted event ----> " + aEvent.type);
return;
}
this.log("Got event ----> " + aEvent.type);
if (this.videoEvents.includes(aEvent.type)) {
this.handleVideoEvent(aEvent);
} else {
this.handleControlEvent(aEvent);
}
}`,
};
}
add_task(async function() {
await pushPref("devtools.chrome.enabled", true);
await runEventPopupTests(TEST_URL, TEST_DATA);
const {tab, inspector, testActor} = await openInspectorForURL(TEST_URL);
const browser = tab.linkedBrowser;
const mm = browser.messageManager;
await mm.loadFrameScript(
`data:,const div = content.document.querySelector("div");` +
`div.addEventListener("click", () => {` +
` /* Do nothing */` +
`});`, false);
await inspector.markup.expandAll();
for (const test of TEST_DATA) {
await checkEventsForNode(test, inspector, testActor);
}
});

Просмотреть файл

@ -4,6 +4,6 @@
<meta charset="utf-8">
</head>
<body>
<video controls></video>
<div></div>
</body>
</html>

Просмотреть файл

@ -94,7 +94,8 @@ async function checkEventsForNode(test, inspector, testActor) {
const cssSelector = nodeFront.nodeName + "#" + nodeFront.id;
for (let i = 0; i < headers.length; i++) {
info("Processing header[" + i + "] for " + cssSelector);
const label = `${cssSelector}.${expected[i].type} (index ${i})`;
info(`${label} START`);
const header = headers[i];
const type = header.querySelector(".event-tooltip-event-type");
@ -136,9 +137,13 @@ async function checkEventsForNode(test, inspector, testActor) {
});
testDiff(editor.getText(), tidiedHandler,
"handler matches for " + cssSelector, ok);
info(`${label} END`);
}
const tooltipHidden = tooltip.once("hidden");
tooltip.hide();
await tooltipHidden;
}
/**