dom/tests/mochitest/bugs/test_protochains.html

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/dom/tests/mochitest/bugs/test_protochains.html	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,59 @@
     1.4 +<!DOCTYPE HTML>
     1.5 +<html>
     1.6 +<!--
     1.7 +https://bugzilla.mozilla.org/show_bug.cgi?id=817420
     1.8 +-->
     1.9 +<head>
    1.10 +  <meta charset="utf-8">
    1.11 +  <title>Test for Bug 817420</title>
    1.12 +  <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
    1.13 +  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
    1.14 +</head>
    1.15 +<body>
    1.16 +<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=817420">Mozilla Bug 817420</a>
    1.17 +<p id="display"></p>
    1.18 +<div id="content" style="display: none">
    1.19 +
    1.20 +</div>
    1.21 +<pre id="test">
    1.22 +<script type="application/javascript">
    1.23 +
    1.24 +/** Test for Bug 817420 **/
    1.25 +is(Object.getPrototypeOf(HTMLElement.prototype), Element.prototype,
    1.26 +   "Must have correct proto chain for HTMLElement.prototype");
    1.27 +is(Object.getPrototypeOf(document.createElementNS(null, "x")),
    1.28 +   Element.prototype,
    1.29 +   "Must have correct proto chain for random element");
    1.30 +is(Object.getPrototypeOf(document.createElement("noSuchElementName")),
    1.31 +   HTMLUnknownElement.prototype,
    1.32 +   "Must have correct proto chain for random HTML element");
    1.33 +
    1.34 +// And check that it's really working as it should
    1.35 +function checkPropPresent(propName, objList, expected)
    1.36 +{
    1.37 +  for (obj of objList) {
    1.38 +    is(propName in obj,
    1.39 +       expected,
    1.40 +       obj + " should " + (expected ? "" : "not ") + "have the property");
    1.41 +  }
    1.42 +}
    1.43 +var objList = [ Element.prototype,
    1.44 +                HTMLElement.prototype,
    1.45 +                document.createElementNS(null, "x"),
    1.46 +                document.createElement("noSuchElementName"),
    1.47 +                document.body ]
    1.48 +checkPropPresent("somePropertyThatBetterNeverExist", objList, false);
    1.49 +Element.prototype.somePropertyThatBetterNeverExist = 1;
    1.50 +checkPropPresent("somePropertyThatBetterNeverExist", objList, true);
    1.51 +
    1.52 +objList = [ HTMLElement.prototype,
    1.53 +            document.createElement("noSuchElementName"),
    1.54 +            document.body ]
    1.55 +checkPropPresent("someOtherPropertyThatBetterNeverExist", objList, false);
    1.56 +HTMLElement.prototype.someOtherPropertyThatBetterNeverExist = 1;
    1.57 +checkPropPresent("someOtherPropertyThatBetterNeverExist", objList, true);
    1.58 +
    1.59 +</script>
    1.60 +</pre>
    1.61 +</body>
    1.62 +</html>

mercurial