dom/tests/mochitest/bugs/test_bug529328.html

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/dom/tests/mochitest/bugs/test_bug529328.html	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,122 @@
     1.4 +<!DOCTYPE HTML>
     1.5 +<html>
     1.6 +<!--
     1.7 +https://bugzilla.mozilla.org/show_bug.cgi?id=529328
     1.8 +-->
     1.9 +<head>
    1.10 +  <title>Test for Bug 529328</title>
    1.11 +  <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
    1.12 +  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
    1.13 +</head>
    1.14 +<body>
    1.15 +<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=529328">Mozilla Bug 529328</a>
    1.16 +<p id="display"></p>
    1.17 +<div id="content" style="display: none">
    1.18 +</div>
    1.19 +<pre id="test">
    1.20 +<script type="application/javascript">
    1.21 +/** Test for Bug 529328 **/
    1.22 +function testDOMTokenList() {
    1.23 +  is(document.body.classList[-1], undefined, "Wrong value for out of bounds access (DOMTokenList)");
    1.24 +  is(document.body.classList[0], undefined, "Wrong value for out of bounds access (DOMTokenList)");
    1.25 +  is(document.body.classList[1], undefined, "Wrong value for out of bounds access (DOMTokenList)");
    1.26 +  is(document.body.classList[2], undefined, "Wrong value for out of bounds access (DOMTokenList)");
    1.27 +  is(document.body.classList.item(-1), null, "Wrong value for out of bounds access (DOMTokenList)");
    1.28 +  is(document.body.classList.item(0), null, "Wrong value for out of bounds access (DOMTokenList)");
    1.29 +  is(document.body.classList.item(1), null, "Wrong value for out of bounds access (DOMTokenList)");
    1.30 +  is(document.body.classList.item(2), null, "Wrong value for out of bounds access (DOMTokenList)");
    1.31 +
    1.32 +  document.body.className = "a b";
    1.33 +  is(document.body.classList[-1], undefined, "Wrong value for out of bounds access (DOMTokenList)");
    1.34 +  is(document.body.classList[0], "a", "Wrong value for in bounds access (DOMTokenList)");
    1.35 +  is(document.body.classList[1], "b", "Wrong value for in bounds access (DOMTokenList)");
    1.36 +  is(document.body.classList[2], undefined, "Wrong value for out of bounds access (DOMTokenList)");
    1.37 +  is(document.body.classList.item(-1), null, "Wrong value for out of bounds access (DOMTokenList)");
    1.38 +  is(document.body.classList.item(0), "a", "Wrong value for in bounds access (DOMTokenList)");
    1.39 +  is(document.body.classList.item(1), "b", "Wrong value for in bounds access (DOMTokenList)");
    1.40 +  is(document.body.classList.item(2), null, "Wrong value for out of bounds access (DOMTokenList)");
    1.41 +}
    1.42 +
    1.43 +function testDOMStringList() {
    1.44 +  is(document.styleSheetSets[-1], undefined, "Wrong value for out of bounds access (DOMStringList)");
    1.45 +  is(document.styleSheetSets[0], undefined, "Wrong value for out of bounds access (DOMStringList)");
    1.46 +  is(document.styleSheetSets[1], undefined, "Wrong value for out of bounds access (DOMStringList)");
    1.47 +  is(document.styleSheetSets[2], undefined, "Wrong value for out of bounds access (DOMStringList)");
    1.48 +  is(document.styleSheetSets.item(-1), null, "Wrong value for out of bounds access (DOMStringList)");
    1.49 +  is(document.styleSheetSets.item(0), null, "Wrong value for out of bounds access (DOMStringList)");
    1.50 +  is(document.styleSheetSets.item(1), null, "Wrong value for out of bounds access (DOMStringList)");
    1.51 +  is(document.styleSheetSets.item(2), null, "Wrong value for out of bounds access (DOMStringList)");
    1.52 +
    1.53 +  var s = document.createElement("style");
    1.54 +  s.title = "a";
    1.55 +  document.head.appendChild(s);
    1.56 +  s = document.createElement("style");
    1.57 +  s.title = "b";
    1.58 +  document.head.appendChild(s);
    1.59 +
    1.60 +  is(document.styleSheetSets[-1], undefined, "Wrong value for out of bounds access (DOMStringList)");
    1.61 +  is(document.styleSheetSets[0], "a", "Wrong value for in bounds access (DOMStringList)");
    1.62 +  is(document.styleSheetSets[1], "b", "Wrong value for in bounds access (DOMStringList)");
    1.63 +  is(document.styleSheetSets[2], undefined, "Wrong value for out of bounds access (DOMStringList)");
    1.64 +  is(document.styleSheetSets.item(-1), null, "Wrong value for out of bounds access (DOMStringList)");
    1.65 +  is(document.styleSheetSets.item(0), "a", "Wrong value for in bounds access (DOMStringList)");
    1.66 +  is(document.styleSheetSets.item(1), "b", "Wrong value for in bounds access (DOMStringList)");
    1.67 +  is(document.styleSheetSets.item(2), null, "Wrong value for out of bounds access (DOMStringList)");
    1.68 +}
    1.69 +
    1.70 +function testMediaList() {
    1.71 +  var s = document.createElement("style");
    1.72 +  document.head.appendChild(s);
    1.73 +  is(s.sheet.media[-1], undefined, "Wrong value for out of bounds access (MediaList)");
    1.74 +  is(s.sheet.media[0], undefined, "Wrong value for out of bounds access (MediaList)");
    1.75 +  is(s.sheet.media[1], undefined, "Wrong value for out of bounds access (MediaList)");
    1.76 +  is(s.sheet.media[2], undefined, "Wrong value for out of bounds access (MediaList) (MediaList)");
    1.77 +  is(s.sheet.media.item(-1), null, "Wrong value for out of bounds access (MediaList)");
    1.78 +  is(s.sheet.media.item(0), null, "Wrong value for out of bounds access (MediaList)");
    1.79 +  is(s.sheet.media.item(1), null, "Wrong value for out of bounds access (MediaList)");
    1.80 +  is(s.sheet.media.item(2), null, "Wrong value for out of bounds access (MediaList) (MediaList)");
    1.81 +
    1.82 +  s.setAttribute("media", "a, b");
    1.83 +
    1.84 +  is(s.sheet.media[-1], undefined, "Wrong value for out of bounds access (MediaList)");
    1.85 +  is(s.sheet.media[0], "a", "Wrong value for in bounds access (MediaList)");
    1.86 +  is(s.sheet.media[1], "b", "Wrong value for in bounds access (MediaList)");
    1.87 +  is(s.sheet.media[2], undefined, "Wrong value for out of bounds access (MediaList) (MediaList)");
    1.88 +  is(s.sheet.media.item(-1), null, "Wrong value for out of bounds access (MediaList)");
    1.89 +  is(s.sheet.media.item(0), "a", "Wrong value for in bounds access (MediaList)");
    1.90 +  is(s.sheet.media.item(1), "b", "Wrong value for in bounds access (MediaList)");
    1.91 +  is(s.sheet.media.item(2), null, "Wrong value for out of bounds access (MediaList) (MediaList)");
    1.92 +}
    1.93 +
    1.94 +function testCSSStyleDeclaration() {
    1.95 +  var s = document.createElement("span");
    1.96 +
    1.97 +  is(s.style[-1], undefined, "Wrong value for out of bounds access (CSSStyleDeclaration)");
    1.98 +  is(s.style[0], undefined, "Wrong value for out of bounds access (CSSStyleDeclaration)");
    1.99 +  is(s.style[1], undefined, "Wrong value for out of bounds access (CSSStyleDeclaration)");
   1.100 +  is(s.style[2], undefined, "Wrong value for out of bounds access (CSSStyleDeclaration)");
   1.101 +  is(s.style.item(-1), "", "Wrong value for out of bounds access (CSSStyleDeclaration)");
   1.102 +  is(s.style.item(0), "", "Wrong value for out of bounds access (CSSStyleDeclaration)");
   1.103 +  is(s.style.item(1), "", "Wrong value for out of bounds access (CSSStyleDeclaration)");
   1.104 +  is(s.style.item(2), "", "Wrong value for out of bounds access (CSSStyleDeclaration)");
   1.105 +
   1.106 +  s.setAttribute("style", "color: blue; z-index: 42;");
   1.107 +
   1.108 +  is(s.style[-1], undefined, "Wrong value for out of bounds access (CSSStyleDeclaration)");
   1.109 +  is(s.style[0], "color", "Wrong value for in bounds access (CSSStyleDeclaration)");
   1.110 +  is(s.style[1], "z-index", "Wrong value for in bounds access (CSSStyleDeclaration)");
   1.111 +  is(s.style[2], undefined, "Wrong value for out of bounds access (CSSStyleDeclaration)");
   1.112 +  is(s.style.item(-1), "", "Wrong value for out of bounds access (CSSStyleDeclaration)");
   1.113 +  is(s.style.item(0), "color", "Wrong value for in bounds access (CSSStyleDeclaration)");
   1.114 +  is(s.style.item(1), "z-index", "Wrong value for in bounds access (CSSStyleDeclaration)");
   1.115 +  is(s.style.item(2), "", "Wrong value for out of bounds access (CSSStyleDeclaration)");
   1.116 +}
   1.117 +
   1.118 +testDOMTokenList();
   1.119 +testDOMStringList();
   1.120 +testMediaList();
   1.121 +testCSSStyleDeclaration();
   1.122 +</script>
   1.123 +</pre>
   1.124 +</body>
   1.125 +</html>

mercurial