mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Merge m-c to m-i
This commit is contained in:
commit
762397036e
@ -841,13 +841,14 @@ MarkupView.prototype = {
|
||||
// we're not viewing.
|
||||
continue;
|
||||
}
|
||||
if (type === "attributes" || type === "characterData"
|
||||
|| type === "events" || type === "pseudoClassLock") {
|
||||
if (type === "attributes" || type === "characterData") {
|
||||
container.update();
|
||||
} else if (type === "childList" || type === "nativeAnonymousChildList") {
|
||||
container.childrenDirty = true;
|
||||
// Update the children to take care of changes in the markup view DOM.
|
||||
this._updateChildren(container, {flash: true});
|
||||
} else if (type === "pseudoClassLock") {
|
||||
container.update();
|
||||
}
|
||||
}
|
||||
|
||||
@ -2546,6 +2547,7 @@ function ElementEditor(aContainer, aNode) {
|
||||
let tagName = this.node.nodeName.toLowerCase();
|
||||
this.tag.textContent = tagName;
|
||||
this.closeTag.textContent = tagName;
|
||||
this.eventNode.style.display = this.node.hasEventListeners ? "inline-block" : "none";
|
||||
|
||||
this.update();
|
||||
this.initialized = true;
|
||||
@ -2641,10 +2643,6 @@ ElementEditor.prototype = {
|
||||
}
|
||||
}
|
||||
|
||||
// Update the event bubble display
|
||||
this.eventNode.style.display = this.node.hasEventListeners ?
|
||||
"inline-block" : "none";
|
||||
|
||||
this.updateTextEditor();
|
||||
},
|
||||
|
||||
|
@ -152,42 +152,6 @@ const TEST_DATA = [
|
||||
}
|
||||
]
|
||||
},
|
||||
// #noevents tests check that dynamically added events are properly displayed
|
||||
// in the markupview
|
||||
{
|
||||
selector: "#noevents",
|
||||
expected: []
|
||||
},
|
||||
{
|
||||
selector: "#noevents",
|
||||
beforeTest: function* (inspector, testActor) {
|
||||
let nodeMutated = inspector.once("markupmutation");
|
||||
yield testActor.eval("window.wrappedJSObject.addNoeventsClickHandler();");
|
||||
yield nodeMutated;
|
||||
},
|
||||
expected: [
|
||||
{
|
||||
type: "click",
|
||||
filename: TEST_URL + ":106",
|
||||
attributes: [
|
||||
"Bubbling",
|
||||
"DOM2"
|
||||
],
|
||||
handler: 'function noeventsClickHandler(event) {\n' +
|
||||
' alert("noevents has an event listener");\n' +
|
||||
'}'
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
selector: "#noevents",
|
||||
beforeTest: function* (inspector, testActor) {
|
||||
let nodeMutated = inspector.once("markupmutation");
|
||||
yield testActor.eval("window.wrappedJSObject.removeNoeventsClickHandler();");
|
||||
yield nodeMutated;
|
||||
},
|
||||
expected: []
|
||||
},
|
||||
];
|
||||
|
||||
add_task(runEventPopupTests);
|
||||
|
@ -102,20 +102,6 @@
|
||||
alert("boundHandleEvent clicked");
|
||||
}
|
||||
};
|
||||
|
||||
function noeventsClickHandler(event) {
|
||||
alert("noevents has an event listener");
|
||||
};
|
||||
|
||||
function addNoeventsClickHandler() {
|
||||
let noevents = document.getElementById("noevents");
|
||||
noevents.addEventListener("click", noeventsClickHandler);
|
||||
};
|
||||
|
||||
function removeNoeventsClickHandler() {
|
||||
let noevents = document.getElementById("noevents");
|
||||
noevents.removeEventListener("click", noeventsClickHandler);
|
||||
};
|
||||
</script>
|
||||
</head>
|
||||
<body onload="init();">
|
||||
|
@ -7,12 +7,12 @@
|
||||
* TEST_DATA array.
|
||||
*/
|
||||
function* runEventPopupTests() {
|
||||
let {inspector, testActor} = yield addTab(TEST_URL).then(openInspector);
|
||||
let {inspector} = yield addTab(TEST_URL).then(openInspector);
|
||||
|
||||
yield inspector.markup.expandAll();
|
||||
|
||||
for (let test of TEST_DATA) {
|
||||
yield checkEventsForNode(test, inspector, testActor);
|
||||
for (let {selector, expected} of TEST_DATA) {
|
||||
yield checkEventsForNode(selector, expected, inspector);
|
||||
}
|
||||
|
||||
// Wait for promises to avoid leaks when running this as a single test.
|
||||
@ -25,36 +25,12 @@ function* runEventPopupTests() {
|
||||
* Generator function that takes a selector and expected results and returns
|
||||
* the event info.
|
||||
*
|
||||
* @param {Object} test
|
||||
* A test object should contain the following properties:
|
||||
* - selector {String} a css selector targeting the node to edit
|
||||
* - expected {Array} array of expected event objects
|
||||
* - type {String} event type
|
||||
* - filename {String} filename:line where the evt handler is defined
|
||||
* - attributes {Array} array of event attributes ({String})
|
||||
* - handler {String} string representation of the handler
|
||||
* - beforeTest {Function} (optional) a function to execute on the page
|
||||
* before running the test
|
||||
* @param {InspectorPanel} inspector The instance of InspectorPanel currently
|
||||
* opened
|
||||
* @param {TestActorFront} testActor
|
||||
* @param {String} selector
|
||||
* Selector pointing at the node to be inspected
|
||||
*/
|
||||
function* checkEventsForNode(test, inspector, testActor) {
|
||||
let {selector, expected, beforeTest} = test;
|
||||
function* checkEventsForNode(selector, expected, inspector) {
|
||||
let container = yield getContainerForSelector(selector, inspector);
|
||||
|
||||
if (typeof beforeTest === "function") {
|
||||
yield beforeTest(inspector, testActor);
|
||||
}
|
||||
|
||||
let evHolder = container.elt.querySelector(".markupview-events");
|
||||
|
||||
if (expected.length === 0) {
|
||||
// if no event is expected, simply check that the event bubble is hidden
|
||||
is(evHolder.style.display, "none", "event bubble should be hidden");
|
||||
return;
|
||||
}
|
||||
|
||||
let tooltip = inspector.markup.tooltip;
|
||||
|
||||
yield selectNode(selector, inspector);
|
||||
|
@ -863,8 +863,6 @@ var NodeFront = protocol.FrontClass(NodeActor, {
|
||||
this._form.incompleteValue = change.incompleteValue;
|
||||
} else if (change.type === "pseudoClassLock") {
|
||||
this._form.pseudoClassLocks = change.pseudoClassLocks;
|
||||
} else if (change.type === "events") {
|
||||
this._form.hasEventListeners = change.hasEventListeners;
|
||||
}
|
||||
},
|
||||
|
||||
@ -1350,32 +1348,6 @@ var WalkerActor = protocol.ActorClass({
|
||||
this.layoutChangeObserver.on("reflows", this._onReflows);
|
||||
this._onResize = this._onResize.bind(this);
|
||||
this.layoutChangeObserver.on("resize", this._onResize);
|
||||
|
||||
this._onEventListenerChange = this._onEventListenerChange.bind(this);
|
||||
eventListenerService.addListenerChangeListener(this._onEventListenerChange);
|
||||
},
|
||||
|
||||
/**
|
||||
* Callback for eventListenerService.addListenerChangeListener
|
||||
* @param nsISimpleEnumerator changesEnum
|
||||
* enumerator of nsIEventListenerChange
|
||||
*/
|
||||
_onEventListenerChange: function(changesEnum) {
|
||||
let changes = changesEnum.enumerate();
|
||||
while (changes.hasMoreElements()) {
|
||||
let current = changes.getNext().QueryInterface(Ci.nsIEventListenerChange);
|
||||
let target = current.target;
|
||||
|
||||
if (this._refMap.has(target)) {
|
||||
let actor = this._refMap.get(target);
|
||||
let mutation = {
|
||||
type: "events",
|
||||
target: actor.actorID,
|
||||
hasEventListeners: actor._hasEventListeners
|
||||
};
|
||||
this.queueMutation(mutation);
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
// Returns the JSON representation of this object over the wire.
|
||||
@ -1442,9 +1414,6 @@ var WalkerActor = protocol.ActorClass({
|
||||
this.layoutChangeObserver = null;
|
||||
releaseLayoutChangesObserver(this.tabActor);
|
||||
|
||||
eventListenerService.removeListenerChangeListener(
|
||||
this._onEventListenerChange);
|
||||
|
||||
this.onMutations = null;
|
||||
|
||||
this.tabActor = null;
|
||||
|
@ -69,7 +69,6 @@ skip-if = buildapp == 'mulet'
|
||||
[test_inspector-hide.html]
|
||||
[test_inspector-insert.html]
|
||||
[test_inspector-mutations-attr.html]
|
||||
[test_inspector-mutations-events.html]
|
||||
[test_inspector-mutations-childlist.html]
|
||||
[test_inspector-mutations-frameload.html]
|
||||
[test_inspector-mutations-value.html]
|
||||
|
@ -1,184 +0,0 @@
|
||||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<!--
|
||||
https://bugzilla.mozilla.org/show_bug.cgi?id=1157469
|
||||
-->
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>Test for Bug 1157469</title>
|
||||
<script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
|
||||
<link rel="stylesheet" type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css">
|
||||
<script type="application/javascript;version=1.8" src="inspector-helpers.js"></script>
|
||||
<script type="application/javascript;version=1.8">
|
||||
|
||||
window.onload = function() {
|
||||
|
||||
const Cu = Components.utils;
|
||||
Cu.import("resource://gre/modules/devtools/Loader.jsm");
|
||||
const {InspectorFront} =
|
||||
devtools.require("devtools/server/actors/inspector");
|
||||
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
|
||||
let inspectee = null;
|
||||
let inspector = null;
|
||||
let walker = null;
|
||||
let eventListener1 = function () {};
|
||||
let eventListener2 = function () {};
|
||||
let eventNode1;
|
||||
let eventNode2;
|
||||
let eventFront1;
|
||||
let eventFront2;
|
||||
|
||||
addAsyncTest(function* setup() {
|
||||
info ("Setting up inspector and walker actors.");
|
||||
let url = document.getElementById("inspectorContent").href;
|
||||
|
||||
yield new Promise(resolve => {
|
||||
attachURL(url, function(err, client, tab, doc) {
|
||||
inspectee = doc;
|
||||
inspector = InspectorFront(client, tab);
|
||||
resolve();
|
||||
});
|
||||
});
|
||||
|
||||
walker = yield inspector.getWalker();
|
||||
ok(walker, "getWalker() should return an actor.");
|
||||
|
||||
runNextTest();
|
||||
});
|
||||
|
||||
addAsyncTest(function* setupEventTest() {
|
||||
eventNode1 = inspectee.querySelector("#a")
|
||||
eventNode2 = inspectee.querySelector("#b")
|
||||
|
||||
eventFront1 = yield walker.querySelector(walker.rootNode, "#a");
|
||||
eventFront2 = yield walker.querySelector(walker.rootNode, "#b");
|
||||
|
||||
runNextTest();
|
||||
});
|
||||
|
||||
addAsyncTest(function* testChangeEventListenerOnSingleNode() {
|
||||
checkNodesHaveNoEventListener();
|
||||
|
||||
info("add event listener on a single node");
|
||||
eventNode1.addEventListener("click", eventListener1);
|
||||
|
||||
let mutations = yield waitForMutations();
|
||||
is(mutations.length, 1, "one mutation expected");
|
||||
is(mutations[0].target, eventFront1, "mutation targets eventFront1");
|
||||
is(mutations[0].type, "events", "mutation type is events");
|
||||
is(mutations[0].hasEventListeners, true, "mutation target should have event listeners");
|
||||
is(eventFront1.hasEventListeners, true, "eventFront1 should have event listeners");
|
||||
|
||||
info("remove event listener on a single node");
|
||||
eventNode1.removeEventListener("click", eventListener1);
|
||||
|
||||
mutations = yield waitForMutations();
|
||||
is(mutations.length, 1, "one mutation expected");
|
||||
is(mutations[0].target, eventFront1, "mutation targets eventFront1");
|
||||
is(mutations[0].type, "events", "mutation type is events");
|
||||
is(mutations[0].hasEventListeners, false, "mutation target should have no event listeners");
|
||||
is(eventFront1.hasEventListeners, false, "eventFront1 should have no event listeners");
|
||||
|
||||
info("perform several event listener changes on a single node")
|
||||
eventNode1.addEventListener("click", eventListener1);
|
||||
eventNode1.addEventListener("click", eventListener2);
|
||||
eventNode1.removeEventListener("click", eventListener1);
|
||||
eventNode1.removeEventListener("click", eventListener2);
|
||||
|
||||
mutations = yield waitForMutations();
|
||||
is(mutations.length, 1, "one mutation expected");
|
||||
is(mutations[0].target, eventFront1, "mutation targets eventFront1");
|
||||
is(mutations[0].type, "events", "mutation type is events");
|
||||
is(mutations[0].hasEventListeners, false, "no event listener expected on mutation target");
|
||||
is(eventFront1.hasEventListeners, false, "no event listener expected on node");
|
||||
|
||||
runNextTest();
|
||||
});
|
||||
|
||||
addAsyncTest(function* testChangeEventsOnSeveralNodes() {
|
||||
checkNodesHaveNoEventListener();
|
||||
|
||||
info("add event listeners on both nodes");
|
||||
eventNode1.addEventListener("click", eventListener1);
|
||||
eventNode2.addEventListener("click", eventListener2);
|
||||
|
||||
let mutations = yield waitForMutations();
|
||||
is(mutations.length, 2, "two mutations expected, one for each modified node");
|
||||
// first mutation
|
||||
is(mutations[0].target, eventFront1, "first mutation targets eventFront1");
|
||||
is(mutations[0].type, "events", "mutation type is events");
|
||||
is(mutations[0].hasEventListeners, true, "mutation target should have event listeners");
|
||||
is(eventFront1.hasEventListeners, true, "eventFront1 should have event listeners");
|
||||
// second mutation
|
||||
is(mutations[1].target, eventFront2, "second mutation targets eventFront2");
|
||||
is(mutations[1].type, "events", "mutation type is events");
|
||||
is(mutations[1].hasEventListeners, true, "mutation target should have event listeners");
|
||||
is(eventFront2.hasEventListeners, true, "eventFront1 should have event listeners");
|
||||
|
||||
info("remove event listeners on both nodes");
|
||||
eventNode1.removeEventListener("click", eventListener1);
|
||||
eventNode2.removeEventListener("click", eventListener2);
|
||||
|
||||
mutations = yield waitForMutations();
|
||||
is(mutations.length, 2, "one mutation registered for event listener change");
|
||||
// first mutation
|
||||
is(mutations[0].target, eventFront1, "first mutation targets eventFront1");
|
||||
is(mutations[0].type, "events", "mutation type is events");
|
||||
is(mutations[0].hasEventListeners, false, "mutation target should have no event listeners");
|
||||
is(eventFront1.hasEventListeners, false, "eventFront2 should have no event listeners");
|
||||
// second mutation
|
||||
is(mutations[1].target, eventFront2, "second mutation targets eventFront2");
|
||||
is(mutations[1].type, "events", "mutation type is events");
|
||||
is(mutations[1].hasEventListeners, false, "mutation target should have no event listeners");
|
||||
is(eventFront2.hasEventListeners, false, "eventFront2 should have no event listeners");
|
||||
|
||||
runNextTest();
|
||||
});
|
||||
|
||||
addAsyncTest(function* testRemoveMissingEvent() {
|
||||
checkNodesHaveNoEventListener();
|
||||
|
||||
info("try to remove an event listener not previously added");
|
||||
eventNode1.removeEventListener("click", eventListener1);
|
||||
|
||||
info("set any attribute on the node to trigger a mutation")
|
||||
eventNode1.setAttribute("data-attr", "somevalue");
|
||||
|
||||
let mutations = yield waitForMutations();
|
||||
is(mutations.length, 1, "expect only one mutation");
|
||||
isnot(mutations.type, "events", "mutation type should not be events");
|
||||
|
||||
runNextTest();
|
||||
});
|
||||
|
||||
function checkNodesHaveNoEventListener() {
|
||||
is(eventFront1.hasEventListeners, false, "eventFront1 hasEventListeners should be false");
|
||||
is(eventFront2.hasEventListeners, false, "eventFront2 hasEventListeners should be false");
|
||||
};
|
||||
|
||||
function waitForMutations() {
|
||||
return new Promise(resolve => {
|
||||
walker.once("mutations", mutations => {
|
||||
resolve(mutations);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
runNextTest();
|
||||
}
|
||||
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=1157469">Mozilla Bug 1157469</a>
|
||||
<a id="inspectorContent" target="_blank" href="inspector-traversal-data.html">Test Document</a>
|
||||
<p id="display"></p>
|
||||
<div id="content" style="display: none">
|
||||
|
||||
</div>
|
||||
<pre id="test">
|
||||
</pre>
|
||||
</body>
|
||||
</html>
|
Loading…
Reference in New Issue
Block a user