Bug 1450151 [wpt PR 10249] - Add test for DocumentAndElementEventHandlers in SVG, a=testonly
☠☠ backed out by de68b0419464 ☠ ☠
authorChris Lilley <chris@w3.org>
Fri, 10 Aug 2018 16:06:49 +0000
changeset 486222 7fe7da39498657e77e5617da25a1343fd52a9205
parent 486221 5fd6d3ad49ea51ccaef614820181cdc0a02ea158
child 486223 b0e2387b578185d46a757db859bc2cb521bf7e5e
push id9719
push userffxbld-merge
push dateFri, 24 Aug 2018 17:49:46 +0000
treeherdermozilla-beta@719ec98fba77 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerstestonly
bugs1450151, 10249
milestone63.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1450151 [wpt PR 10249] - Add test for DocumentAndElementEventHandlers in SVG, a=testonly Automatic update from web-platform-testsMerge pull request #10249 from dstorey/svg-document-element-events Add test for DocumentAndElementEventHandlers in SVG -- wpt-commits: 1529e32ac8073c48e872e7d705a10daa24decbbf wpt-pr: 10249
testing/web-platform/meta/MANIFEST.json
testing/web-platform/tests/svg/types/scripted/event-handler-all-document-element-events.svg
--- a/testing/web-platform/meta/MANIFEST.json
+++ b/testing/web-platform/meta/MANIFEST.json
@@ -391371,16 +391371,22 @@
     ]
    ],
    "svg/types/scripted/SVGLengthList-getItem.html": [
     [
      "/svg/types/scripted/SVGLengthList-getItem.html",
      {}
     ]
    ],
+   "svg/types/scripted/event-handler-all-document-element-events.svg": [
+    [
+     "/svg/types/scripted/event-handler-all-document-element-events.svg",
+     {}
+    ]
+   ],
    "touch-events/historical.html": [
     [
      "/touch-events/historical.html",
      {}
     ]
    ],
    "touch-events/idlharness.window.js": [
     [
@@ -635304,16 +635310,20 @@
   "svg/types/scripted/SVGLengthList-basics.html": [
    "58d0e937bedeb2615ce74039046909d8ea53e990",
    "testharness"
   ],
   "svg/types/scripted/SVGLengthList-getItem.html": [
    "c81a23394468f2e4d586d4e6ece5be713470d485",
    "testharness"
   ],
+  "svg/types/scripted/event-handler-all-document-element-events.svg": [
+   "fa813dd1dd31987d2792aaa14a5f7ea996a8054d",
+   "testharness"
+  ],
   "svg/types/scripted/resources/SVGLengthList-helper.js": [
    "3cf888b7dbaeb370ef1b34409540337dee2c8e33",
    "support"
   ],
   "testharness_runner.html": [
    "1cc80a270e2c1e8f0bcb8dc4878a75d9ce01717a",
    "support"
   ],
new file mode 100644
--- /dev/null
+++ b/testing/web-platform/tests/svg/types/scripted/event-handler-all-document-element-events.svg
@@ -0,0 +1,55 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<svg xmlns="http://www.w3.org/2000/svg"
+     xmlns:h="http://www.w3.org/1999/xhtml">
+    <title>DocumentAndElementEventHandlers</title>
+    <metadata>
+        <h:link rel="help" href="https://svgwg.org/svg2-draft/types.html#InterfaceSVGElement"/>
+    </metadata>
+    <h:script src="/resources/testharness.js"/>
+    <h:script src="/resources/testharnessreport.js"/>
+    <script><![CDATA[
+        "use strict";
+        setup({ explicit_done: true });
+
+        const names = ["oncut","oncopy","onpaste"];
+
+        for (const name of names) {
+            const withoutOn = name.substring(2);
+
+            test(() => {
+                assert_true(SVGElement.prototype.hasOwnProperty(name),
+                    `${SVGElement.prototype.constructor.name} has an own property named "${name}"`);
+                assert_false(name in Element.prototype, `Element.prototype must not contain a "${name}" property`);
+            }, `${name}: DocumentAndElementEventHandlers must be on SVGElement not Element`);
+
+            test(() => {
+                const svgElement = document.createElementNS("http://www.w3.org/2000/svg", "g");
+
+                assert_equals(svgElement[name], null,
+                    `The default value of the property is null for a ${svgElement.constructor.name} instance`);
+            }, `${name}: the default value must be null`);
+
+            test(() => {
+                const el = document.createElementNS("http://www.w3.org/2000/svg", "g");
+                el.setAttribute(name, `window.${name}Happened = true;`);
+                const compiledHandler = el[name];
+
+                assert_equals(typeof compiledHandler, "function", `The ${name} property must be a function`);
+                compiledHandler();
+                assert_true(window[name + "Happened"], "Calling the handler must run the code");
+            }, `${name}: the content attribute must be compiled into a function as the corresponding property`);
+
+            test(() => {
+                const el = document.createElementNS("http://www.w3.org/2000/svg", "g");
+                el.setAttribute(name, `window.${name}Happened2 = true;`);
+
+                el.dispatchEvent(new Event(withoutOn));
+
+                assert_true(window[name + "Happened2"], "Dispatching an event must run the code");
+            }, `${name}: the content attribute must execute when an event is dispatched`);
+        }
+
+        done();
+  ]]></script>
+</svg>
+