Commit 80978f70 authored by Navid Zolghadr's avatar Navid Zolghadr Committed by Commit Bot

Use NotFoundError instead of InvalidPointerId

This cl follows the new pointerevent spec which
uses more common WebIDL specified exception
NotFoundError instead of defining new
InvalidPointerId exception.

Bug: 885321
Change-Id: I28e946ffcb96c9fb4f70c76a4b9c09be620f981d
Reviewed-on: https://chromium-review.googlesource.com/1231990Reviewed-by: default avatarDave Tapuska <dtapuska@chromium.org>
Reviewed-by: default avatarElla Ge <eirage@chromium.org>
Reviewed-by: default avatarYuki Shiino <yukishiino@chromium.org>
Commit-Queue: Navid Zolghadr <nzolghadr@chromium.org>
Cr-Commit-Position: refs/heads/master@{#592903}
parent 6bd4db44
<!doctype html>
<html>
<head>
<title>Pointer Event: releasePointerCapture DOMException - InvalidPointerId</title>
<meta name="assert" content="releasePointerCapture DOMException - InvalidPointerId"/>
<title>Pointer Event: releasePointerCapture DOMException - NotFoundError</title>
<meta name="assert" content="releasePointerCapture DOMException - NotFoundError"/>
<meta content="text/html; charset=UTF-8" http-equiv="Content-Type"/>
<link rel="author" title="Microsoft" href="http://www.microsoft.com/"/>
<link rel="help" href="http://www.w3.org/wiki/PointerEvents/TestAssertions">
<meta name="assert" content="When the releasePointerCapture method is invoked, if the provided pointerId value does not match any of the active pointers, a DOMException with the name InvalidPointerId must be thrown."/>
<meta name="assert" content="When the releasePointerCapture method is invoked, if the provided pointerId value does not match any of the active pointers, a DOMException with the name NotFoundError must be thrown."/>
<link rel="stylesheet" type="text/css" href="pointerevent_styles.css">
<!-- /resources/testharness.js -->
<script src="/resources/testharness.js"></script>
......@@ -15,13 +15,13 @@
<script type="text/javascript" src="pointerevent_support.js"></script>
<script type="text/javascript">
var detected_pointertypes = {};
var test_pointerEvent = async_test("releasePointerCapture: DOMException InvalidPointerId"); // set up test harness
var test_pointerEvent = async_test("releasePointerCapture: DOMException NotFoundError"); // set up test harness
// showPointerTypes is defined in pointerevent_support.js
// Requirements: the callback function will reference the test_pointerEvent object and
// will fail unless the async_test is created with the var name "test_pointerEvent".
add_completion_callback(showPointerTypes);
var invalid_pointerId = 314159265358973923;
var INVALID_POINTERID = 314159265358973923;
function run() {
var target0 = document.getElementById("target0");
......@@ -32,17 +32,11 @@
on_event(listener, "pointermove", function (event) {
detected_pointertypes[event.pointerType] = true;
try {
listener.releasePointerCapture(invalid_pointerId);
test_pointerEvent.step(function() {
assert_throws("NotFoundError", function(){ listener.releasePointerCapture(INVALID_POINTERID); },
"It should not be possible to release capture an invalid pointer id");
});
test_pointerEvent.step(function () {
assert_true(false, "DOMException not thrown. Expected: InvalidPointerId should have been thrown");
});
} catch (e) {
test_pointerEvent.step(function () {
assert_true(e.name == "InvalidPointerId", "DOMException should be InvalidPointerId");
});
}
test_pointerEvent.done(); // complete test
});
......@@ -56,11 +50,11 @@
</head>
<body onload="run()">
<div id="listener"></div>
<h1> Pointer Event: releasePointerCapture() DOMException - InvalidPointerId</h1>
<h1> Pointer Event: releasePointerCapture() DOMException - NotFoundError</h1>
<h4>
Test Description:
Upon invocation of the releasePointerCapture method, if the provided pointerId value does not match any of the
active pointers, a DOMException with the name InvalidPointerId must be thrown.
active pointers, a DOMException with the name NotFoundError must be thrown.
</h4>
<br />
<div id="target0">
......@@ -73,4 +67,4 @@
</div>
<div id="log"></div>
</body>
</html>
\ No newline at end of file
</html>
<!doctype html>
<html>
<head>
<title>Pointer Event: gotPiontercapture is fired first.</title>
<title>Pointer Event: gotPointercapture is fired first.</title>
<meta content="text/html; charset=UTF-8" http-equiv="Content-Type" />
<link rel="author" title="Microsoft" href="http://www.microsoft.com/" />
<link rel="help" href="http://www.w3.org/wiki/PointerEvents/TestAssertions">
<meta name="assert" content="When the setPointerCapture method is invoked, if the provided pointerId value does not match any of the active pointers, a DOMException with the name InvalidPointerId must be thrown." />
<meta name="assert" content="When the setPointerCapture method is invoked, if the provided pointerId value does not match any of the active pointers, a DOMException with the name NotFountError must be thrown." />
<link rel="stylesheet" type="text/css" href="pointerevent_styles.css">
<!-- /resources/testharness.js -->
<script src="/resources/testharness.js"></script>
......@@ -14,7 +14,7 @@
<script type="text/javascript" src="pointerevent_support.js"></script>
<script type="text/javascript">
var detected_pointertypes = {};
var test_pointerEvent = async_test("setPointerCapture: DOMException InvalidPointerId"); // set up test harness
var test_pointerEvent = async_test("setPointerCapture: DOMException NotFoundError"); // set up test harness
// showPointerTypes is defined in pointerevent_support.js
// Requirements: the callback function will reference the test_pointerEvent object and
// will fail unless the async_test is created with the var name "test_pointerEvent".
......@@ -29,27 +29,19 @@
on_event(target0, "pointerdown", function (event) {
detected_pointertypes[event.pointerType] = true;
try {
listener.setPointerCapture(INVALID_POINTERID);
test_pointerEvent.step(function () {
assert_true(false, "DOMException: InvalidPointerId should have been thrown.");
});
} catch (e) {
test_pointerEvent.step(function () {
assert_equals(e.name, "InvalidPointerId", "DOMException should be InvalidPointerId");
});
}
test_pointerEvent.step(function() {
assert_throws("NotFoundError", function(){ listener.setPointerCapture(INVALID_POINTERID); },
"It should not be possible to capture an invalid pointer id");
});
test_pointerEvent.done(); // complete test
});
}
</script>
</head>
<body onload="run()">
<h1>Pointer Event: DOMException InvalidPointerId</h1>
<h1>Pointer Event: DOMException NotFoundError</h1>
<h4>Test Description:
When the setPointerCapture method is invoked, if the provided pointerId value does not match any of the active pointers, a DOMException with the name InvalidPointerId must be thrown.
When the setPointerCapture method is invoked, if the provided pointerId value does not match any of the active pointers, a DOMException with the name NotFoundError must be thrown.
</h4>
<br />
<div id="target0">
......@@ -62,4 +54,4 @@
</div>
<div id="log"></div>
</body>
</html>
\ No newline at end of file
</html>
......@@ -140,12 +140,6 @@ const struct DOMExceptionEntry {
// https://github.com/WICG/BackgroundSync/issues/124
{DOMExceptionCode::kPermissionDeniedError, "PermissionDeniedError",
"User or security policy denied the request."},
// Pointer Events
// https://w3c.github.io/pointerevents/
// Pointer Events introduced a new DOMException outside Web IDL.
{DOMExceptionCode::kInvalidPointerId, "InvalidPointerId",
"PointerId was invalid."},
};
unsigned short ToLegacyErrorCode(DOMExceptionCode exception_code) {
......
......@@ -3781,8 +3781,9 @@ void Element::setPointerCapture(int pointer_id,
if (GetDocument().GetFrame()) {
if (!GetDocument().GetFrame()->GetEventHandler().IsPointerEventActive(
pointer_id)) {
exception_state.ThrowDOMException(DOMExceptionCode::kInvalidPointerId,
"InvalidPointerId");
exception_state.ThrowDOMException(
DOMExceptionCode::kNotFoundError,
"No active pointer with the given id is found.");
} else if (!isConnected() ||
(GetDocument().GetPage() && GetDocument()
.GetPage()
......@@ -3802,8 +3803,9 @@ void Element::releasePointerCapture(int pointer_id,
if (GetDocument().GetFrame()) {
if (!GetDocument().GetFrame()->GetEventHandler().IsPointerEventActive(
pointer_id)) {
exception_state.ThrowDOMException(DOMExceptionCode::kInvalidPointerId,
"InvalidPointerId");
exception_state.ThrowDOMException(
DOMExceptionCode::kNotFoundError,
"No active pointer with the given id is found.");
} else {
GetDocument().GetFrame()->GetEventHandler().ReleasePointerCapture(
pointer_id, this);
......
......@@ -103,12 +103,6 @@ enum class DOMExceptionCode : ExceptionCode {
// https://github.com/WICG/BackgroundSync/issues/124
kPermissionDeniedError,
// Pointer Events
// https://w3c.github.io/pointerevents/
// Pointer Events introduced a new DOMException outside Web IDL.
// The name "InvalidPointerId" does not end with the suffix "Error".
kInvalidPointerId,
kNumOfCodes,
};
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment