https://github.com/web-platform-tests/wpt
Raw File
Tip revision: 5de28d46eab8eb2f610a77aca0bb004e872a3e3d authored by Hallvord R. M. Steen on 28 February 2014, 09:55:18 UTC
dropping superfluous variable declaration
Tip revision: 5de28d4
Document-createEvent.html
<!DOCTYPE html>
<meta charset=utf-8>
<title>Document.createEvent</title>
<link rel=help href="http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html#dom-document-createevent">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<div id="log"></div>
<script>
// TODO: values of attributes
function testAlias(arg, iface) {
  test(function() {
    if (iface === "Event" || iface in window) {
      var ev = document.createEvent(arg);
      assert_true(ev instanceof window[iface]);
      assert_true(ev instanceof Event);
    }
  }, arg + " should be an alias for " + iface + ".");
}
[
  ["Event", "Event"],
  ["Events", "Event"],
  ["HTMLEvents", "Event"],
  ["MouseEvent", "MouseEvent"],
  ["MouseEvents", "MouseEvent"],
  ["UIEvent", "UIEvent"],
  ["UIEvents", "UIEvent"]
].forEach(function(alias) {
  testAlias(alias[0], alias[1]);
  testAlias(alias[0].toLowerCase(), alias[1]);
  testAlias(alias[0].toUpperCase(), alias[1]);
});

test(function() {
  assert_throws("NOT_SUPPORTED_ERR", function() {
    var evt = document.createEvent("foo");
  });
  assert_throws("NOT_SUPPORTED_ERR", function() {
    // 'LATIN CAPITAL LETTER I WITH DOT ABOVE' (U+0130)
    var evt = document.createEvent("U\u0130Event");
  });
}, "Should throw NOT_SUPPORTED_ERR for unrecognized arguments");
</script>
back to top