Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(232)

Unified Diff: third_party/WebKit/LayoutTests/fast/events/constructors/touch-touchevent-constructor.html

Issue 1415673004: Added web-exposed constructor for Touch and TouchEvent (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Use appendVector, added temporary tests Created 5 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/LayoutTests/fast/events/constructors/touch-touchevent-constructor.html
diff --git a/third_party/WebKit/LayoutTests/fast/events/constructors/touch-touchevent-constructor.html b/third_party/WebKit/LayoutTests/fast/events/constructors/touch-touchevent-constructor.html
new file mode 100644
index 0000000000000000000000000000000000000000..fa925526b5cbaa00547d8c8cc4271dd6c01c81e2
--- /dev/null
+++ b/third_party/WebKit/LayoutTests/fast/events/constructors/touch-touchevent-constructor.html
@@ -0,0 +1,127 @@
+<!--
+ TODO(chongz): Remove this file and import from w3c tests after approved.
dtapuska 2015/11/04 21:36:32 same
+ https://github.com/w3c/touch-events/issues/45
+-->
+<!DOCTYPE HTML>
+<html>
+<!--
+ Test cases for Touch Events v2 Recommendation
+ https://w3c.github.io/touch-events/
+
+ These tests are based on Mozilla-Nokia-Google's single-touch tests.
+
+ The primary purpose of the tests in this document is checking that the createTouch and
+ createTouchList interfaces of the Touch Events APIs are correctly implemented.
+ Other interactions are covered in other test files.
+
+ This document references Test Assertions (abbrev TA below) written by Cathy Chan
+ http://www.w3.org/2010/webevents/wiki/TestAssertions
+-->
+
+<head>
+<title>Touch Events Touch and TouchEvent Constructor Tests</title>
+<meta name="viewport" content="width=device-width">
+<script src="../../../resources/testharness.js"></script>
+<script src="../../../resources/testharnessreport.js"></script>
+<script src="touch-support.js"></script>
+<script>
+setup({
+ explicit_done: true
+});
+
+function run() {
+ var target0 = document.getElementById("target0");
+ var touch1, touch2;
+ var touchEvent1;
+
+ test(function() {
+ touch1 = new Touch({
+ identifier: 42,
+ target: target0,
+ pageX: 15,
dtapuska 2015/11/04 21:36:32 Should we verify that these are parsed as double v
+ pageY: 20,
+ screenX: 35,
+ screenY: 40,
+ clientX: 10,
+ clientY: 15,
+ });
+ check_Touch_object(touch1);
+ assert_equals(touch1.target, target0, "touch.target is target0");
+ assert_equals(touch1.identifier, 42, "touch.identifier is requested value");
+ assert_equals(touch1.pageX, 15, "touch.pageX is requested value");
+ assert_equals(touch1.pageY, 20, "touch.pageY is requested value");
+ assert_equals(touch1.screenX, 35, "touch.screenX is requested value");
+ assert_equals(touch1.screenY, 40, "touch.screenY is requested value");
+ // Constructor does not calculate clientX/Y in v2
+ assert_equals(touch1.clientX, 10, "touch.clientX is requested value.");
+ assert_equals(touch1.clientY, 15, "touch.clientY is requested value.");
+ }, "Touch constructor exists and creates a Touch object with requested properties");
+
+
+ test(function() {
+ touch1 = new Touch({
+ identifier: 45,
+ target: target0,
+ pageX: 45,
+ pageY: 50,
+ screenX: 65,
+ screenY: 60,
+ clientX: 70,
+ clientY: 75,
+ });
+ touch2 = new Touch({
+ identifier: 52,
+ target: target0,
+ pageX: 15,
+ pageY: 20,
+ screenX: 15,
+ screenY: 20,
+ clientX: 15,
+ clientY: 20,
+ });
+
+ touchEvent1 = new TouchEvent("ontouchstart", {
+ touches: [touch1, touch2],
+ targetTouches: [touch1],
+ altKey: true,
+ metaKey: false,
+ });
+
+ check_TouchEvent(touchEvent1);
+ assert_equals(touchEvent1.type, "ontouchstart", "touchEvent.type is requested value");
+ assert_equals(touchEvent1.touches[0], touch1, "touchEvent.touches[0] is requested value");
+ assert_equals(touchEvent1.touches[1], touch2, "touchEvent.touches[1] is requested value");
+ assert_equals(touchEvent1.touches.length, 2, "touchEvent.touches.length is requested value");
dtapuska 2015/11/04 21:36:32 I'd expect the length checks first before accessin
+ assert_equals(touchEvent1.targetTouches[0], touch1, "touchEvent.targetTouches[0] is requested value");
+ assert_equals(touchEvent1.targetTouches.length, 1, "touchEvent.targetTouches.length is requested value");
+ assert_equals(touchEvent1.changedTouches.length, 0, "touchEvent.changedTouches.length is requested value");
+ assert_equals(touchEvent1.altKey, true, "touchEvent.altKey is requested value");
+ assert_equals(touchEvent1.metaKey, false, "touchEvent.metaKey is requested value");
+ assert_equals(touchEvent1.ctrlKey, false, "touchEvent.ctrlKey is requested value");
+ assert_equals(touchEvent1.shiftKey, false, "touchEvent.shiftKey is requested value.");
+ }, "TouchEvent constructor exists and creates a TouchEvent object with requested properties");
+
+ target0.innerHTML = "Test complete."
+ done();
+}
+</script>
+<style>
+div {
+ margin: 0em;
+ padding: 2em;
+}
+
+#target0 {
+ background: yellow;
+ border: 1px solid orange;
+}
+</style>
+</head>
+
+<body onload="run()">
+ <h1>Touch Events: Touch and TouchEvent constructor tests</h1>
+ <div id="target0">Please wait for test to complete...</div>
+ <div id="log"></div>
+</body>
+
+</html>

Powered by Google App Engine
This is Rietveld 408576698