Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(214)

Unified Diff: LayoutTests/fast/dom/script-tests/event-handlers.js

Issue 37283002: Drop NotEnumerable for the on* event handler IDL attributes (again) (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: rm redundant test Created 7 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « LayoutTests/fast/dom/global-event-handlers.html ('k') | LayoutTests/fast/dom/window-event-handlers.html » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: LayoutTests/fast/dom/script-tests/event-handlers.js
diff --git a/LayoutTests/fast/dom/script-tests/event-handlers.js b/LayoutTests/fast/dom/script-tests/event-handlers.js
new file mode 100644
index 0000000000000000000000000000000000000000..22af617ace6fef8796ee4a2dee84d9f38a0e37d5
--- /dev/null
+++ b/LayoutTests/fast/dom/script-tests/event-handlers.js
@@ -0,0 +1,78 @@
+function getObject(interface) {
+ switch(interface) {
+ case "Element":
+ var e = document.createElementNS("http://example.com/", "example");
+ assert_true(e instanceof Element);
+ assert_false(e instanceof HTMLElement);
+ assert_false(e instanceof SVGElement);
+ return e;
+ case "HTMLElement":
+ var e = document.createElement("html");
+ assert_true(e instanceof HTMLElement);
+ return e;
+ case "HTMLBodyElement":
+ var e = document.createElement("body");
+ assert_true(e instanceof HTMLBodyElement);
+ return e;
+ case "HTMLFormElement":
+ var e = document.createElement("form");
+ assert_true(e instanceof HTMLFormElement);
+ return e;
+ case "HTMLFrameSetElement":
+ var e = document.createElement("frameset");
+ assert_true(e instanceof HTMLFrameSetElement);
+ return e;
+ case "SVGElement":
+ var e = document.createElementNS("http://www.w3.org/2000/svg", "rect");
+ assert_true(e instanceof SVGElement);
+ return e;
+ case "Document":
+ assert_true(document instanceof Document);
+ return document;
+ case "Window":
+ assert_true(window instanceof Window);
+ return window;
+ }
+ assert_unreached();
+}
+function testSet(interface, attribute) {
+ test(function() {
+ var object = getObject(interface);
+ function nop() {}
+ assert_equals(object[attribute], null, "Initially null");
+ object[attribute] = nop;
+ assert_equals(object[attribute], nop, "Return same function");
+ object[attribute] = "";
+ assert_equals(object[attribute], null, "Return null after setting string");
+ object[attribute] = null;
+ assert_equals(object[attribute], null, "Finally null");
+ }, "Set " + interface + "." + attribute);
+}
+function testReflect(interface, attribute) {
+ test(function() {
+ var element = getObject(interface);
+ assert_false(element.hasAttribute(attribute), "Initially missing");
+ element.setAttribute(attribute, "return");
+ assert_equals(element.getAttribute(attribute), "return", "Return same string");
+ assert_equals(typeof element[attribute], "function", "Convert to function");
+ element.removeAttribute(attribute);
+ }, "Reflect " + interface + "." + attribute);
+}
+// Object.propertyIsEnumerable cannot be used because it doesn't
+// work with properties inherited through the prototype chain.
+function getEnumerable(interface) {
+ var enumerable = {};
+ for (var attribute in getObject(interface)) {
+ enumerable[attribute] = true;
+ }
+ return enumerable;
+}
+var enumerableCache = {};
+function testEnumerate(interface, attribute) {
+ if (!(interface in enumerableCache)) {
+ enumerableCache[interface] = getEnumerable(interface);
+ }
+ test(function() {
+ assert_true(enumerableCache[interface][attribute]);
+ }, "Enumerate " + interface + "." + attribute);
+}
« no previous file with comments | « LayoutTests/fast/dom/global-event-handlers.html ('k') | LayoutTests/fast/dom/window-event-handlers.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698