Make event.html more useful
authorAryeh Gregor <ayg@aryeh.name>
Sun, 01 Apr 2012 07:45:50 -0600
changeset 716 ae1d76c1054e
parent 715 98d33b30b6ab
child 717 195aab1749d2
Make event.html more useful

This catches exceptions from execCommand(), fixes a couple of the tests
so they're correct, and reorders the tests to test the least relevant
things last.
conformancetest/event.html
--- a/conformancetest/event.html	Thu Mar 22 12:47:49 2012 -0600
+++ b/conformancetest/event.html	Sun Apr 01 07:45:50 2012 -0600
@@ -216,7 +216,17 @@
 		//	finalTarget.dispatchEvent(e);
 		//}
 
-		document.execCommand(command, false, value);
+		var exception = null;
+		try {
+			document.execCommand(command, false, value);
+		} catch(e) {
+			exception = e;
+		}
+
+		test(function() {
+			assert_equals(exception, null, "Unexpected exception");
+		}, obj.name + ": execCommand() must not throw, "
+		+ (cancel ? "canceled" : "uncanceled"));
 
 		test(function() {
 			assert_equals(beforeInputEvents.length, target ? 1 : 0,
@@ -234,13 +244,16 @@
 			assert_equals(e.bubbles, true, "event.bubbles");
 			assert_equals(e.cancelable, true, "event.cancelable");
 			assert_equals(e.defaultPrevented, false, "event.defaultPrevented");
-			assert_equals(e.isTrusted, true, "event.isTrusted");
 			assert_equals(e.command, command, "e.command");
 			assert_equals(e.value, value, "e.value");
-			assert_equals(Object.getPrototypeOf(e.original), EditingBeforeInputEvent,
+			assert_own_property(window, "EditingBeforeInputEvent",
+				"window.EditingBeforeInputEvent must exist");
+			assert_equals(Object.getPrototypeOf(e.original),
+				EditingBeforeInputEvent.prototype,
 				"event prototype");
 			assert_true(originalContents.isEqualNode(div),
 				"div contents not yet changed");
+			assert_equals(e.isTrusted, true, "event.isTrusted");
 		}, obj.name + ": beforeinput event, " + (cancel ? "canceled" : "uncanceled"));
 
 		test(function() {
@@ -259,12 +272,18 @@
 			assert_equals(e.bubbles, true, "event.bubbles");
 			assert_equals(e.cancelable, false, "event.cancelable");
 			assert_equals(e.defaultPrevented, false, "event.defaultPrevented");
-			assert_equals(e.isTrusted, true, "event.isTrusted");
 			assert_equals(e.command, command, "e.command");
 			assert_equals(e.value, value, "e.value");
-			assert_equals(Object.getPrototypeOf(e.original), EditingInputEvent,
+			assert_own_property(window, "EditingInputEvent",
+				"window.EditingInputEvent must exist");
+			assert_equals(Object.getPrototypeOf(e.original),
+				EditingInputEvent.prototype,
 				"event prototype");
+			assert_equals(e.isTrusted, true, "event.isTrusted");
 		}, obj.name + ": input event, " + (cancel ? "canceled" : "uncanceled"));
 	});
 });
+
+// Thanks, Gecko.
+document.body.bgColor = "";
 </script>