pointerevent_setpointercapture_disconnected-manual.html 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. <!doctype html>
  2. <html>
  3. <head>
  4. <title>setPointerCapture() throws on disconnected node</title>
  5. <meta name="viewport" content="width=device-width">
  6. <link rel="stylesheet" type="text/css" href="pointerevent_styles.css">
  7. <script src="/resources/testharness.js"></script>
  8. <!--script src="/resources/testharnessreport.js"></script-->
  9. <script src="pointerevent_support.js"></script>
  10. <script src="mochitest_support_internal.js"></script>
  11. <script type="text/javascript">
  12. var detected_pointertypes = {};
  13. add_completion_callback(showPointerTypes);
  14. var test_setPointerCapture = async_test("setPointerCapture: DOMException InvalidStateError");
  15. function run() {
  16. var target0 = document.getElementById("target0");
  17. var target1 = document.getElementById("target1");
  18. target1.parentNode.removeChild(target1);
  19. on_event(target0, "pointerdown", function (event) {
  20. detected_pointertypes[ event.pointerType ] = true;
  21. try {
  22. target1.setPointerCapture(event.pointerId);
  23. test_setPointerCapture.step(function() {
  24. assert_unreached("DOMException: InvalidStateError should have been thrown.");
  25. });
  26. } catch (e) {
  27. // TA: 13.4
  28. test_setPointerCapture.step(function() {
  29. assert_equals(e.name, "InvalidStateError", "DOMException should be InvalidStateError");
  30. });
  31. }
  32. test_setPointerCapture.done();
  33. });
  34. }
  35. </script>
  36. </head>
  37. <body onload="run()">
  38. <h1>Pointer Event: DOMException InvalidStateError</h1>
  39. <!--
  40. <h4>Test Description:
  41. When the setPointerCapture method is invoked, if the target node does not participate in its ownerDocument's tree, a DOMException with the name InvalidStateError must be thrown.
  42. </h4>
  43. <br>
  44. -->
  45. <div id="target0">
  46. Use the mouse, touch or pen to contact this box.
  47. </div>
  48. <div id="target1"></div>
  49. <div id="complete-notice">
  50. <p>The following pointer types were detected: <span id="pointertype-log"></span>.</p>
  51. </div>
  52. <div id="log"></div>
  53. </body>
  54. </html>