diff options
Diffstat (limited to 'testing/web-platform/tests/uievents/legacy-domevents-tests/approved')
6 files changed, 311 insertions, 0 deletions
diff --git a/testing/web-platform/tests/uievents/legacy-domevents-tests/approved/ProcessingInstruction.DOMCharacterDataModified.html b/testing/web-platform/tests/uievents/legacy-domevents-tests/approved/ProcessingInstruction.DOMCharacterDataModified.html new file mode 100644 index 000000000..2da0a389e --- /dev/null +++ b/testing/web-platform/tests/uievents/legacy-domevents-tests/approved/ProcessingInstruction.DOMCharacterDataModified.html @@ -0,0 +1,32 @@ +<!DOCTYPE html> +<html> +<head> +<title> ProcessingInstruction.data and DOMCharacterDataModified event </title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +</head> +<body> +<div id=log></div> + +<iframe id="helper" style="display: none"></iframe> + +<script> + var description = "Test Description: " + + "DOMCharacterDataModified event fires after ProcessingInstruction.data have been modified, " + + "but the node itself has not been inserted or deleted. The proximal event target of this " + + "event shall be the ProcessingInstruction node."; + + var t = async_test(description); + + var HELPER = document.getElementById("helper"); + + HELPER.onload = t.step_func(function() + { + assert_true(HELPER.contentWindow.TestResult); + t.done(); + }); + + HELPER.src = "./support/ProcessingInstruction.DOMCharacterDataModified.xml"; +</script> +</body> +</html> diff --git a/testing/web-platform/tests/uievents/legacy-domevents-tests/approved/dispatchEvent.click.checkbox.html b/testing/web-platform/tests/uievents/legacy-domevents-tests/approved/dispatchEvent.click.checkbox.html new file mode 100644 index 000000000..8cb548f84 --- /dev/null +++ b/testing/web-platform/tests/uievents/legacy-domevents-tests/approved/dispatchEvent.click.checkbox.html @@ -0,0 +1,80 @@ +<!DOCTYPE html> +<html> +<head> +<title> MouseEvent: Default action and synthetic click event </title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +</head> +<body> +<div id=log></div> + +<div style="display: none"> + <input type="checkbox" id="target"> + <button id="button"> Click Here </button> +</div> + +<script> + setup({explicit_done:true}); + var EVENT = "click"; + var TARGET = document.getElementById("target"); + var BUTTON = document.getElementById("button"); + var state; + + var description = "Test Description: " + + "MouseEvent: Default action is performed when a synthetic click event is dispatched on a checkbox element"; + + BUTTON.addEventListener(EVENT, TestEvent, true); + TARGET.addEventListener(EVENT, TestEvent, true); + + window.onload = function() + { + state = TARGET.checked; + BUTTON.click(); + } + + function TestEvent(evt) + { + if (BUTTON == evt.target) + { + var e; + test(function() + { + BUTTON.removeEventListener(EVENT, TestEvent, true); + + e = document.createEvent("MouseEvent"); + e.initMouseEvent(EVENT, /* type */ + false, /* bubbles */ + true, /* cancelable */ + window, /* view */ + 1, /* detail */ + 0, /* screenX */ + 0, /* screenY */ + 0, /* clientX */ + 0, /* clientY */ + false, /* ctrlKey */ + false, /* altKey */ + false, /* shiftKey */ + false, /* metaKey */ + 0, /* button */ + null /* relatedTarget */); + + assert_array_equals([TARGET.checked, e.type, e.bubbles], [state, EVENT, false]); + + }, "Checkbox state is unchanged before the synthetic click event is dispatched"); + + TARGET.dispatchEvent(e); + } + else if (TARGET == evt.target) + { + test(function() + { + assert_array_equals([TARGET.checked, evt.type, evt.bubbles], [!state, EVENT, false]); + + }, description); + + done(); + } + } +</script> +</body> +</html> diff --git a/testing/web-platform/tests/uievents/legacy-domevents-tests/approved/domnodeinserted.html b/testing/web-platform/tests/uievents/legacy-domevents-tests/approved/domnodeinserted.html new file mode 100644 index 000000000..e5064d8d4 --- /dev/null +++ b/testing/web-platform/tests/uievents/legacy-domevents-tests/approved/domnodeinserted.html @@ -0,0 +1,26 @@ +<!DOCTYPE html> +<title>MutationEvent: DOMNodeInserted Event Type</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<div id=log></div> + +<div id="target" style="display: none"></div> + +<script> +var EVENT = "DOMNodeInserted"; +var TARGET; +var NODE; + +var t = async_test("Test Description: DOMNodeInserted event fires when a node has been added as a child of another node."); + +TARGET = document.getElementById("target"); + +TARGET.addEventListener(EVENT, t.step_func(function(evt) +{ + assert_equals(evt.type, EVENT); + t.done(); +}), true); + +NODE = document.createElement("INPUT"); +TARGET.appendChild(NODE); +</script> diff --git a/testing/web-platform/tests/uievents/legacy-domevents-tests/approved/stopImmediatePropagation.effect.html b/testing/web-platform/tests/uievents/legacy-domevents-tests/approved/stopImmediatePropagation.effect.html new file mode 100644 index 000000000..a414d6029 --- /dev/null +++ b/testing/web-platform/tests/uievents/legacy-domevents-tests/approved/stopImmediatePropagation.effect.html @@ -0,0 +1,71 @@ +<!DOCTYPE html> +<html> +<head> +<title> Event.stopImmediatePropagation() immediate effect </title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +</head> +<body> +<div id=log></div> + +<table id="table" border="1" style="display: none"> + <tbody id="table-body"> + <tr id="table-row"> + <td id="table-cell">Shady Grove</td> + <td>Aeolian</td> + </tr> + <tr id="parent"> + <td id="target">Over the river, Charlie</td> + <td>Dorian</td> + </tr> + </tbody> +</table> + +<script> + var EVENT = "foo"; + var TARGET = document.getElementById("target"); + var PARENT = document.getElementById("parent"); + var TBODY = document.getElementById("table-body"); + var TABLE = document.getElementById("table"); + var BODY = document.body; + var HTML = document.documentElement; + var CurrentTargets = [window, document, HTML, BODY, TABLE, TBODY, PARENT, TARGET]; + var ExpectResult = [window, window, document, document, HTML, HTML, BODY, BODY, TABLE]; + var ActualResult = []; + var ExpectListeners = [0,1,0,1,0,1,0,1,0]; + var ActualListeners = []; + + var description = "Test Description: " + + "stopImmediatePropagation() prevents other event listeners from being triggered and, unlike " + + "Event.stopPropagation(), its effect must be immediate. Once it has been called, further calls " + + "to this method have no additional effect."; + + test(function() + { + for (var i=0; i < CurrentTargets.length; i++) + { + CurrentTargets[i].addEventListener(EVENT, function(e){TestEvent(e, 0)}, true); + CurrentTargets[i].addEventListener(EVENT, function(e){TestEvent(e, 1)}, true); + } + + var evt = document.createEvent("Event"); + evt.initEvent(EVENT, true, true); + TARGET.dispatchEvent(evt); + + assert_array_equals(ActualResult, ExpectResult, "ActualResult"); + assert_array_equals(ActualListeners, ExpectListeners, "ActualListeners"); + + }, description); + + function TestEvent(evt, i) + { + ActualResult.push(evt.currentTarget); + ActualListeners.push(i); + if ((1 == evt.eventPhase) && (TABLE == evt.currentTarget) && (0 == i)) + { + evt.stopImmediatePropagation(); + } + } +</script> +</body> +</html> diff --git a/testing/web-platform/tests/uievents/legacy-domevents-tests/approved/stopPropagation.deferred.effect.html b/testing/web-platform/tests/uievents/legacy-domevents-tests/approved/stopPropagation.deferred.effect.html new file mode 100644 index 000000000..93489c63b --- /dev/null +++ b/testing/web-platform/tests/uievents/legacy-domevents-tests/approved/stopPropagation.deferred.effect.html @@ -0,0 +1,70 @@ +<!DOCTYPE html> +<html> +<head> +<title> Event.stopPropagation() deferred effect </title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +</head> +<body> +<div id=log></div> + +<table id="table" border="1" style="display: none"> + <tbody id="table-body"> + <tr id="table-row"> + <td id="table-cell">Shady Grove</td> + <td>Aeolian</td> + </tr> + <tr id="parent"> + <td id="target">Over the river, Charlie</td> + <td>Dorian</td> + </tr> + </tbody> +</table> + +<script> + var EVENT = "foo"; + var TARGET = document.getElementById("target"); + var PARENT = document.getElementById("parent"); + var TBODY = document.getElementById("table-body"); + var TABLE = document.getElementById("table"); + var BODY = document.body; + var HTML = document.documentElement; + var CurrentTargets = [window, document, HTML, BODY, TABLE, TBODY, PARENT, TARGET]; + var ExpectResult = [window, window, document, document, HTML, HTML, BODY, BODY, TABLE, TABLE]; + var ActualResult = []; + var ExpectListeners = [0,1,0,1,0,1,0,1,0,1]; + var ActualListeners = []; + + var description = "Test Description: " + + "stopPropagation() prevents other event listeners from being triggered but its effect must be " + + "deferred until all event listeners attached on the Event.currentTarget have been triggered."; + + test(function() + { + for (var i=0; i < CurrentTargets.length; i++) + { + CurrentTargets[i].addEventListener(EVENT, function(e){TestEvent(e, 0)}, true); + CurrentTargets[i].addEventListener(EVENT, function(e){TestEvent(e, 1)}, true); + } + + var evt = document.createEvent("Event"); + evt.initEvent(EVENT, true, true); + TARGET.dispatchEvent(evt); + + assert_array_equals(ActualResult, ExpectResult, "ActualResult"); + assert_array_equals(ActualListeners, ExpectListeners, "ActualListeners"); + + }, description); + + function TestEvent(evt, i) + { + ActualResult.push(evt.currentTarget); + ActualListeners.push(i); + if ((1 == evt.eventPhase) && (TABLE == evt.currentTarget) && (0 == i)) + { + evt.stopPropagation(); + } + } +</script> +</body> +</html> diff --git a/testing/web-platform/tests/uievents/legacy-domevents-tests/approved/support/ProcessingInstruction.DOMCharacterDataModified.xml b/testing/web-platform/tests/uievents/legacy-domevents-tests/approved/support/ProcessingInstruction.DOMCharacterDataModified.xml new file mode 100644 index 000000000..4c95ae29d --- /dev/null +++ b/testing/web-platform/tests/uievents/legacy-domevents-tests/approved/support/ProcessingInstruction.DOMCharacterDataModified.xml @@ -0,0 +1,32 @@ +<?xml version="1.0"?> +<root> + <head xmlns="http://www.w3.org/1999/xhtml"> + <title> ProcessingInstruction.data and DOMCharacterDataModified event </title> + </head> + <div id="log" xmlns="http://www.w3.org/1999/xhtml"></div> + + <pi><?foo bar?></pi> + + <script type="text/javascript" xmlns="http://www.w3.org/1999/xhtml"> + <![CDATA[ + var EVENT = "DOMCharacterDataModified"; + var TARGET = document.getElementsByTagName('pi')[0].firstChild; + var TestResult = false; + + TARGET.addEventListener(EVENT, TestEvent, false); + TARGET.data = "new" + TARGET.data; + + function TestEvent(evt) + { + if ((EVENT == evt.type) && (TARGET == evt.target) && ("newbar" == evt.newValue)) + { + TestResult = true; + } + else + { + TestResult = false; + } + } + ]]> + </script> +</root>
\ No newline at end of file |