Source/WebCore/ChangeLog

 12016-06-06 Nael Ouedraogo <nael.ouedraogo@crf.canon.fr>
 2
 3 Creating a TouchList with non Touch items should throw an exception
 4 https://bugs.webkit.org/show_bug.cgi?id=158302
 5
 6 Reviewed by NOBODY (OOPS!).
 7
 8 Only Touch items should be passed to CreateTouchList function as per specification
 9 (https://w3c.github.io/touch-events/#extensions-to-the-document-interface).
 10 CreateTouchList function behavior is modified. An exception is thrown when non Touch items
 11 are passed as parameters instead of adding null items in the TouchList.
 12
 13 Tests have been modified to check whether behavior of CreateTouchList is correct.
 14
 15 * bindings/js/JSDocumentCustom.cpp:
 16 (WebCore::JSDocument::createTouchList):
 17 * dom/Document.idl:
 18
1192016-06-05 Sam Weinig <sam@webkit.org>
220
321 Add experimental support for spring based CSS animations

Source/WebCore/bindings/js/JSDocumentCustom.cpp

@@JSValue JSDocument::createTouchList(ExecState& state)
133133{
134134 auto touchList = TouchList::create();
135135
136  for (size_t i = 0; i < state.argumentCount(); i++)
137  touchList->append(JSTouch::toWrapped(state.argument(i)));
 136 for (size_t i = 0; i < state.argumentCount(); ++i) {
 137 if (!state.uncheckedArgument(i).inherits(JSTouch::info()))
 138 return JSValue::decode(throwArgumentTypeError(state, i, "touches", "Document", "createTouchList", "TouchList"));
138139
139  return toJS(&state, globalObject(), touchList);
 140 auto* item = JSTouch::toWrapped(state.argument(i));
 141 ASSERT(item);
 142 touchList->append(item);
 143 }
 144 return toJSNewlyCreated(&state, globalObject(), WTFMove(touchList));
140145}
141146#endif
142147

Source/WebCore/dom/Document.idl

301301 optional long webkitRadiusY = 0,
302302 optional unrestricted float webkitRotationAngle = NaN,
303303 optional unrestricted float webkitForce = NaN);
304  [NewObject, Custom, RaisesException] TouchList createTouchList();
 304 [NewObject, Custom] TouchList createTouchList(Touch... touches);
305305#endif
306306
307307#if defined(LANGUAGE_JAVASCRIPT) && LANGUAGE_JAVASCRIPT

LayoutTests/ChangeLog

 12016-06-06 Nael Ouedraogo <nael.ouedraogo@crf.canon.fr>
 2
 3 Creating a TouchList with non Touch items should throw an exception
 4 https://bugs.webkit.org/show_bug.cgi?id=158302
 5
 6 Reviewed by NOBODY (OOPS!).
 7
 8 Only Touch items should be passed to CreateTouchList function as
 9 per specification (https://w3c.github.io/touch-events/#extensions-to-the-document-interface).
 10
 11 Tests have been modified to check whether behavior of CreateTouchList is correct.
 12
 13 * fast/events/touch/document-create-touch-list-crash-expected.txt:
 14 * fast/events/touch/document-create-touch-list-expected.txt:
 15 * fast/events/touch/script-tests/document-create-touch-list-crash.js:
 16 * fast/events/touch/script-tests/document-create-touch-list.js:
 17
1182016-06-05 Sam Weinig <sam@webkit.org>
219
320 Add experimental support for spring based CSS animations

LayoutTests/fast/events/touch/document-create-touch-list-crash-expected.txt

@@This test ensures that WebKit doesn't crash when the document.createTouchList AP
33On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
44
55
6 PASS document.createTouchList(document).item(0) is null
7 PASS document.createTouchList({"a":1}).item(0) is null
8 PASS document.createTouchList(new Array(5)).item(0) is null
9 PASS document.createTouchList("string").item(0) is null
10 PASS document.createTouchList(null).item(0) is null
11 PASS document.createTouchList(undefined).item(0) is null
12 PASS tl.length is 3
 6PASS document.createTouchList(document).item(0) threw exception TypeError: Argument 1 ('touches') to Document.createTouchList must be an instance of TouchList.
 7PASS document.createTouchList({"a":1}).item(0) threw exception TypeError: Argument 1 ('touches') to Document.createTouchList must be an instance of TouchList.
 8PASS document.createTouchList(new Array(5)).item(0) threw exception TypeError: Argument 1 ('touches') to Document.createTouchList must be an instance of TouchList.
 9PASS document.createTouchList("string").item(0) threw exception TypeError: Argument 1 ('touches') to Document.createTouchList must be an instance of TouchList.
 10PASS document.createTouchList(null).item(0) threw exception TypeError: Argument 1 ('touches') to Document.createTouchList must be an instance of TouchList.
 11PASS document.createTouchList(undefined).item(0) threw exception TypeError: Argument 1 ('touches') to Document.createTouchList must be an instance of TouchList.
 12PASS document.createTouchList() did not throw exception.
 13PASS document.createTouchList().length is 0
 14PASS document.createTouchList(t, document, t2); threw exception TypeError: Argument 2 ('touches') to Document.createTouchList must be an instance of TouchList.
 15PASS tl.length is 2
1316PASS tl.item(0) is non-null.
14 PASS tl.item(1) is null
15 PASS tl.item(2) is non-null.
 17PASS tl.item(1) is non-null.
1618PASS successfullyParsed is true
1719
1820TEST COMPLETE

LayoutTests/fast/events/touch/document-create-touch-list-expected.txt

@@PASS ts.touches[0].identifier is 12341
1717PASS ts.touches[0].clientX is 60
1818PASS ts.touches[1].screenY is 120
1919PASS ts.ctrlKey is true
 20PASS document.createTouchList(1, 2) threw exception TypeError: Argument 1 ('touches') to Document.createTouchList must be an instance of TouchList.
2021PASS successfullyParsed is true
2122
2223TEST COMPLETE

LayoutTests/fast/events/touch/script-tests/document-create-touch-list-crash.js

11description("This test ensures that WebKit doesn't crash when the document.createTouchList API is called with non-Touch parameters");
22
3 shouldBeNull('document.createTouchList(document).item(0)');
4 shouldBeNull('document.createTouchList({"a":1}).item(0)');
5 shouldBeNull('document.createTouchList(new Array(5)).item(0)');
6 shouldBeNull('document.createTouchList("string").item(0)');
7 shouldBeNull('document.createTouchList(null).item(0)');
8 shouldBeNull('document.createTouchList(undefined).item(0)');
 3shouldThrow('document.createTouchList(document).item(0)');
 4shouldThrow('document.createTouchList({"a":1}).item(0)');
 5shouldThrow('document.createTouchList(new Array(5)).item(0)');
 6shouldThrow('document.createTouchList("string").item(0)');
 7shouldThrow('document.createTouchList(null).item(0)');
 8shouldThrow('document.createTouchList(undefined).item(0)');
 9shouldNotThrow('document.createTouchList()');
 10shouldBe('document.createTouchList().length', '0');
911
1012var t = document.createTouch(window, document.body, 12341, 60, 65, 100, 105);
1113var t2 = document.createTouch(window, document.body, 12342, 50, 55, 115, 120);
12 var tl = document.createTouchList(t, document, t2);
1314
14 shouldBe('tl.length', '3');
 15shouldThrow('document.createTouchList(t, document, t2);');
 16
 17var tl = document.createTouchList(t, t2);
 18shouldBe('tl.length','2');
1519shouldBeNonNull('tl.item(0)');
16 shouldBeNull('tl.item(1)');
17 shouldBeNonNull('tl.item(2)');
 20shouldBeNonNull('tl.item(1)');
1821
1922isSuccessfullyParsed();

LayoutTests/fast/events/touch/script-tests/document-create-touch-list.js

@@try {
3737}
3838
3939// Test createTouchList with invalid arguments which throws exceptions.
40 try {
41  var tl = document.createTouchList(1, 2);
42 } catch(e) {
43  testFailed("An exception was thrown: " + e.message);
44 }
 40shouldThrow("document.createTouchList(1, 2)");
 41
4542isSuccessfullyParsed();
4643