Test event dispatching in documents without a browsing context

This commit is contained in:
Anthony Ramine 2016-02-24 12:38:11 +01:00
parent d85ee09bc7
commit 0455b0b301
2 changed files with 48 additions and 35 deletions

View file

@ -1,5 +1,5 @@
[Event-dispatch-bubbles-false.html] [Event-dispatch-bubbles-false.html]
type: testharness type: testharness
[Event.dispatchEvent with Event.bubbles set to false.] [In document with a browsing context: Event.dispatchEvent with Event.bubbles set to false.]
expected: FAIL expected: FAIL

View file

@ -19,32 +19,23 @@
</tbody> </tbody>
</table> </table>
<script> <script>
test(function() { function targetsForDocumentChain(document) {
var event_type = "click"; return [
var target = document.getElementById("target");
var targets = [
window,
document, document,
document.documentElement, document.documentElement,
document.body, document.body,
document.getElementById("table"), document.getElementById("table"),
document.getElementById("table-body"), document.getElementById("table-body"),
document.getElementById("parent"), document.getElementById("parent")
target,
];
var expected_targets = targets.concat(target);
var phases = [
Event.CAPTURING_PHASE,
Event.CAPTURING_PHASE,
Event.CAPTURING_PHASE,
Event.CAPTURING_PHASE,
Event.CAPTURING_PHASE,
Event.CAPTURING_PHASE,
Event.CAPTURING_PHASE,
Event.AT_TARGET,
Event.AT_TARGET,
]; ];
}
function testChain(document, targetParents, phases, label) {
test(function() {
var event_type = "click";
var target = document.getElementById("target");
var targets = targetParents.concat(target);
var expected_targets = targets.concat(target);
var actual_targets = [], actual_phases = []; var actual_targets = [], actual_phases = [];
var test_event = function(evt) { var test_event = function(evt) {
@ -64,5 +55,27 @@ test(function() {
assert_array_equals(actual_targets, expected_targets, "targets"); assert_array_equals(actual_targets, expected_targets, "targets");
assert_array_equals(actual_phases, phases, "phases"); assert_array_equals(actual_phases, phases, "phases");
}, "Event.dispatchEvent with Event.bubbles set to false."); }, label + ": Event.dispatchEvent with Event.bubbles set to false.");
}
var phasesForDocumentChain = [
Event.CAPTURING_PHASE,
Event.CAPTURING_PHASE,
Event.CAPTURING_PHASE,
Event.CAPTURING_PHASE,
Event.CAPTURING_PHASE,
Event.CAPTURING_PHASE,
Event.AT_TARGET,
Event.AT_TARGET,
];
chainWithWindow = [window].concat(targetsForDocumentChain(document));
testChain(
document, chainWithWindow, [Event.CAPTURING_PHASE].concat(phasesForDocumentChain),
"In document with a browsing context");
var documentClone = document.cloneNode(true);
testChain(
documentClone, targetsForDocumentChain(documentClone), phasesForDocumentChain,
"In document without a browsing context");
</script> </script>