Wed, 31 Dec 2014 06:09:35 +0100
Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.
michael@0 | 1 | <?xml version="1.0"?> |
michael@0 | 2 | <html xmlns="http://www.w3.org/1999/xhtml" attr="value"> |
michael@0 | 3 | <!-- |
michael@0 | 4 | https://bugzilla.mozilla.org/show_bug.cgi?id=384003 |
michael@0 | 5 | --> |
michael@0 | 6 | <head> |
michael@0 | 7 | <title>Test for Bug 384003</title> |
michael@0 | 8 | <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script> |
michael@0 | 9 | <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/> |
michael@0 | 10 | </head> |
michael@0 | 11 | <body> |
michael@0 | 12 | <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=384003">Mozilla Bug 384003</a> |
michael@0 | 13 | <p id="display"></p> |
michael@0 | 14 | <div id="content" style="display: none"> |
michael@0 | 15 | |
michael@0 | 16 | </div> |
michael@0 | 17 | <pre id="test" xmlns:foo="http://www.foo.org"><foo:foo/> |
michael@0 | 18 | <script type="application/javascript"> |
michael@0 | 19 | <![CDATA[ |
michael@0 | 20 | |
michael@0 | 21 | /** Test for Bug 384003 **/ |
michael@0 | 22 | |
michael@0 | 23 | |
michael@0 | 24 | function resolverTest(expr, resolver, result, extype) { |
michael@0 | 25 | if (!extype) { |
michael@0 | 26 | extype = 0; |
michael@0 | 27 | } |
michael@0 | 28 | try { |
michael@0 | 29 | is(document.evaluate(expr, document, resolver, |
michael@0 | 30 | XPathResult.FIRST_ORDERED_NODE_TYPE, null). |
michael@0 | 31 | singleNodeValue, |
michael@0 | 32 | result, |
michael@0 | 33 | "Wrong XPathResult"); |
michael@0 | 34 | if (extype) { |
michael@0 | 35 | ok(false, "Should have got an exception!"); |
michael@0 | 36 | } |
michael@0 | 37 | } catch(ex) { |
michael@0 | 38 | is(ex.name, extype, "Wrong exception"); |
michael@0 | 39 | } |
michael@0 | 40 | } |
michael@0 | 41 | |
michael@0 | 42 | // Expression should return document element. |
michael@0 | 43 | // Document resolver |
michael@0 | 44 | resolverTest("*", document, document.documentElement); |
michael@0 | 45 | // Element resolver |
michael@0 | 46 | resolverTest("*", document.documentElement, document.documentElement); |
michael@0 | 47 | // Attribute resolver |
michael@0 | 48 | resolverTest("*", document.documentElement.getAttributeNode("attr"), |
michael@0 | 49 | document.documentElement); |
michael@0 | 50 | // Text node resolver |
michael@0 | 51 | resolverTest("*", document.documentElement.firstChild, |
michael@0 | 52 | document.documentElement); |
michael@0 | 53 | // Comment node resolver |
michael@0 | 54 | resolverTest("*", document.documentElement.firstChild.nextSibling, |
michael@0 | 55 | document.documentElement); |
michael@0 | 56 | |
michael@0 | 57 | // Expression should return foo element, but because of the |
michael@0 | 58 | // resolver it may throw an exception. |
michael@0 | 59 | var foo = document.getElementById("test").firstChild; |
michael@0 | 60 | // Document resolver |
michael@0 | 61 | resolverTest("//foo:foo", document, foo, "NamespaceError"); |
michael@0 | 62 | // Element resolver |
michael@0 | 63 | resolverTest("//foo:foo", document.documentElement, foo, "NamespaceError"); |
michael@0 | 64 | // Attribute resolver |
michael@0 | 65 | resolverTest("//foo:foo", document.documentElement.getAttributeNode("attr"), |
michael@0 | 66 | foo, "NamespaceError"); |
michael@0 | 67 | // Text node resolver |
michael@0 | 68 | resolverTest("//foo:foo", document.documentElement.firstChild, |
michael@0 | 69 | foo, "NamespaceError"); |
michael@0 | 70 | // Comment node resolver |
michael@0 | 71 | resolverTest("//foo:foo", document.documentElement.firstChild.nextSibling, |
michael@0 | 72 | foo, "NamespaceError"); |
michael@0 | 73 | // Function resolver |
michael@0 | 74 | resolverTest("//foo:foo", |
michael@0 | 75 | function(p) { return (p == "foo") ? "http://www.foo.org" : ""; }, |
michael@0 | 76 | foo); |
michael@0 | 77 | // Element resolver, which has definition for foo namespace |
michael@0 | 78 | resolverTest("//foo:foo", foo.parentNode, foo); |
michael@0 | 79 | |
michael@0 | 80 | ]]> |
michael@0 | 81 | </script> |
michael@0 | 82 | </pre> |
michael@0 | 83 | </body> |
michael@0 | 84 | </html> |