dom/tests/mochitest/bugs/test_bug393974.html

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/dom/tests/mochitest/bugs/test_bug393974.html	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,68 @@
     1.4 +<!DOCTYPE HTML>
     1.5 +<html>
     1.6 +<!--
     1.7 +https://bugzilla.mozilla.org/show_bug.cgi?id=393974
     1.8 +-->
     1.9 +<head>
    1.10 +  <title>Test for Bug 393974</title>
    1.11 +  <script type="text/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=393974">Mozilla Bug 393974</a>
    1.16 +<p id="display"></p>
    1.17 +<div id="content" style="display: none">
    1.18 +  
    1.19 +</div>
    1.20 +<pre id="test">
    1.21 +<script class="testbody" type="text/javascript">
    1.22 +
    1.23 +SimpleTest.waitForExplicitFinish();
    1.24 +
    1.25 +function test()
    1.26 +{
    1.27 +  // Create a tree walker with a filter which creates a cycle...
    1.28 +  var tw = document.createTreeWalker(document, NodeFilter.SHOW_ALL,
    1.29 +                                     function(n)
    1.30 +                                     {
    1.31 +                                       // force the closure to contain the
    1.32 +                                       // global object, in case a future
    1.33 +                                       // optimization might minimize the
    1.34 +                                       // function's captured environment
    1.35 +                                       if ("foo" + window == "fooPIRATES!")
    1.36 +                                         return NodeFilter.FILTER_ACCEPT;
    1.37 +                                       return NodeFilter.FILTER_REJECT;
    1.38 +                                     });
    1.39 +
    1.40 +  // That should have been enough to create a leak, but we should do at least
    1.41 +  // a couple tests while we're here so that this document doesn't show up as
    1.42 +  // having no tests pass *or* fail.
    1.43 +
    1.44 +  ok(tw.firstChild() === null, "shouldn't be a first child");
    1.45 +  ok(tw.currentNode === document, "should be unchanged");
    1.46 +
    1.47 +  ok(tw.lastChild() === null, "shouldn't be a last child");
    1.48 +  ok(tw.currentNode === document, "should be unchanged");
    1.49 +
    1.50 +  ok(tw.nextNode() === null, "shouldn't be a next node");
    1.51 +  ok(tw.currentNode === document, "should be unchanged");
    1.52 +
    1.53 +  ok(tw.nextSibling() === null, "shouldn't be a next sibling");
    1.54 +  ok(tw.currentNode === document, "should be unchanged");
    1.55 +
    1.56 +  ok(tw.parentNode() === null, "shouldn't be a parent node");
    1.57 +  ok(tw.currentNode === document, "should be unchanged");
    1.58 +
    1.59 +  ok(tw.previousNode() === null, "shouldn't be a previous node");
    1.60 +  ok(tw.currentNode === document, "should be unchanged");
    1.61 +
    1.62 +  ok(tw.previousSibling() === null, "shouldn't be a previous sibling");
    1.63 +  ok(tw.currentNode === document, "should be unchanged");
    1.64 +}
    1.65 +
    1.66 +addLoadEvent(test);
    1.67 +addLoadEvent(SimpleTest.finish);
    1.68 +</script>
    1.69 +</pre>
    1.70 +</body>
    1.71 +</html>

mercurial