Changeset 201747 in webkit


Ignore:
Timestamp:
Jun 7, 2016 3:06:53 AM (8 years ago)
Author:
nael.ouedraogo@crf.canon.fr
Message:

Creating a TouchList with non Touch items should throw an exception
https://bugs.webkit.org/show_bug.cgi?id=158302

Reviewed by Youenn Fablet.

Source/WebCore:

Only Touch items should be passed to CreateTouchList function as per specification
(https://w3c.github.io/touch-events/#extensions-to-the-document-interface).
CreateTouchList function behavior is modified. An exception is thrown when non Touch items
are passed as parameters instead of adding null items in the TouchList.

Tests have been modified to check whether behavior of CreateTouchList is correct.

  • bindings/js/JSDocumentCustom.cpp:

(WebCore::JSDocument::createTouchList):

  • dom/Document.idl:

LayoutTests:

Only Touch items should be passed to CreateTouchList function as
per specification (https://w3c.github.io/touch-events/#extensions-to-the-document-interface).

Tests have been modified to check whether behavior of CreateTouchList is correct.

  • fast/events/touch/document-create-touch-list-crash-expected.txt:
  • fast/events/touch/document-create-touch-list-expected.txt:
  • fast/events/touch/script-tests/document-create-touch-list-crash.js:
  • fast/events/touch/script-tests/document-create-touch-list.js:
Location:
trunk
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r201746 r201747  
     12016-06-07  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 Youenn Fablet.
     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-07  Joseph Pecoraro  <pecoraro@apple.com>
    219
  • trunk/LayoutTests/fast/events/touch/document-create-touch-list-crash-expected.txt

    r119158 r201747  
    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 Touch.
     7PASS document.createTouchList({"a":1}).item(0) threw exception TypeError: Argument 1 ('touches') to Document.createTouchList must be an instance of Touch.
     8PASS document.createTouchList(new Array(5)).item(0) threw exception TypeError: Argument 1 ('touches') to Document.createTouchList must be an instance of Touch.
     9PASS document.createTouchList("string").item(0) threw exception TypeError: Argument 1 ('touches') to Document.createTouchList must be an instance of Touch.
     10PASS document.createTouchList(null).item(0) threw exception TypeError: Argument 1 ('touches') to Document.createTouchList must be an instance of Touch.
     11PASS document.createTouchList(undefined).item(0) threw exception TypeError: Argument 1 ('touches') to Document.createTouchList must be an instance of Touch.
     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 Touch.
     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
  • trunk/LayoutTests/fast/events/touch/document-create-touch-list-expected.txt

    r138843 r201747  
    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 Touch.
    2021PASS successfullyParsed is true
    2122
  • trunk/LayoutTests/fast/events/touch/script-tests/document-create-touch-list-crash.js

    r119158 r201747  
    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();
  • trunk/LayoutTests/fast/events/touch/script-tests/document-create-touch-list.js

    r138843 r201747  
    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
  • trunk/Source/WebCore/ChangeLog

    r201743 r201747  
     12016-06-07  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 Youenn Fablet.
     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-06  Commit Queue  <commit-queue@webkit.org>
    220
  • trunk/Source/WebCore/bindings/js/JSDocumentCustom.cpp

    r201739 r201747  
    134134    auto touchList = TouchList::create();
    135135
    136     for (size_t i = 0; i < state.argumentCount(); i++)
    137         touchList->append(JSTouch::toWrapped(state.argument(i)));
    138 
    139     return toJS(&state, globalObject(), touchList);
     136    for (size_t i = 0; i < state.argumentCount(); ++i) {
     137        auto* item = JSTouch::toWrapped(state.uncheckedArgument(i));
     138        if (!item)
     139            return JSValue::decode(throwArgumentTypeError(state, i, "touches", "Document", "createTouchList", "Touch"));
     140
     141        touchList->append(item);
     142    }
     143    return toJSNewlyCreated(&state, globalObject(), WTFMove(touchList));
    140144}
    141145#endif
  • trunk/Source/WebCore/dom/Document.idl

    r200550 r201747  
    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
Note: See TracChangeset for help on using the changeset viewer.