Home | History | Annotate | Download | only in xpath
      1 <html>
      2 <head>
      3 <link rel="stylesheet" href="../js/resources/js-test-style.css">
      4 <script src="../js/resources/js-test-pre.js"></script>
      5 <script>
      6     if (window.layoutTestController) {
      7         layoutTestController.waitUntilDone();
      8         layoutTestController.dumpAsText();
      9     }
     10 
     11     var dummyResolverCalled = false;
     12     var foundNode;
     13     function dummyResolver() {
     14         dummyResolverCalled = true;
     15         return "http://www.w3.org/1999/xhtml";
     16     }
     17 
     18     function test() {
     19         var iframe = document.createElement("iframe");
     20         document.body.appendChild(iframe);
     21         var doc = iframe.contentWindow.document;
     22         doc.open();
     23         doc.write("<html><body><div></div></body></html>");
     24         doc.close();
     25         document.body.removeChild(iframe);
     26         foundNode = doc.evaluate("//dummyns:div", doc, dummyResolver, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue;
     27 
     28         testPassed("Did not crash.");
     29         shouldBeTrue("dummyResolverCalled");
     30         shouldBe("foundNode.toString()", "\"[object HTMLDivElement]\"");
     31 
     32         if (window.layoutTestController)
     33             layoutTestController.notifyDone();
     34     }
     35 </script>
     36 </head>
     37 <body onload="test()">
     38 <p>Ensure that using XPath namespace resolver with a detached iframe doesn't crash.</p>
     39 <div id="console"></div>
     40 </body>
     41 </html>
     42