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 | <!DOCTYPE HTML> |
michael@0 | 2 | <html> |
michael@0 | 3 | <!-- |
michael@0 | 4 | https://bugzilla.mozilla.org/show_bug.cgi?id=366946 |
michael@0 | 5 | --> |
michael@0 | 6 | <head> |
michael@0 | 7 | <title>Test for Bug 366946</title> |
michael@0 | 8 | <script type="text/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=366946">Mozilla Bug 366946</a> |
michael@0 | 13 | <p id="display"></p> |
michael@0 | 14 | <div id="content" style="display: none"> |
michael@0 | 15 | <div id="1"></div> |
michael@0 | 16 | <div id="2"></div> |
michael@0 | 17 | <div id="3"></div> |
michael@0 | 18 | </div> |
michael@0 | 19 | <pre id="test"> |
michael@0 | 20 | <script class="testbody" type="text/javascript"> |
michael@0 | 21 | /** Test for Bug 366946 **/ |
michael@0 | 22 | SimpleTest.waitForExplicitFinish(); |
michael@0 | 23 | |
michael@0 | 24 | addLoadEvent(function() { |
michael@0 | 25 | var doc1 = document; |
michael@0 | 26 | |
michael@0 | 27 | // Set up a new document. |
michael@0 | 28 | var doc2 = document.implementation.createDocument('', '', null); |
michael@0 | 29 | |
michael@0 | 30 | // Copy some nodes into doc2 |
michael@0 | 31 | var node1 = doc2.importNode(doc1.getElementById('1'), false); |
michael@0 | 32 | var node2 = doc2.importNode(doc1.getElementById('1'), false); |
michael@0 | 33 | node1.appendChild(node2); |
michael@0 | 34 | doc2.appendChild(node1); |
michael@0 | 35 | |
michael@0 | 36 | // Create two ranges in doc1 to compare. |
michael@0 | 37 | var range1 = doc1.createRange(); |
michael@0 | 38 | range1.setStart(doc1.getElementById('1'), 0); |
michael@0 | 39 | range1.setEnd(doc1.getElementById('2'), 0); |
michael@0 | 40 | |
michael@0 | 41 | var range2 = doc1.createRange(); |
michael@0 | 42 | range2.setStart(doc1.getElementById('2'), 0); |
michael@0 | 43 | range2.setEnd(doc1.getElementById('3'), 0); |
michael@0 | 44 | |
michael@0 | 45 | // Create a range in doc2. |
michael@0 | 46 | var range3 = doc2.createRange(); |
michael@0 | 47 | range3.setStart(node1, 0); |
michael@0 | 48 | range3.setEnd(node2, 0); |
michael@0 | 49 | |
michael@0 | 50 | // Compare range1 and range2: Should return 1. |
michael@0 | 51 | try { |
michael@0 | 52 | var result1 = range2.compareBoundaryPoints(Range.START_TO_START, range1); |
michael@0 | 53 | } |
michael@0 | 54 | catch (ex) { |
michael@0 | 55 | } |
michael@0 | 56 | ok(result1 === 1, "range1 and range2 are compared correctly."); |
michael@0 | 57 | |
michael@0 | 58 | // Compare range1 and range3: Should throw DOMException WRONG_DOCUMENT_ERR. |
michael@0 | 59 | try { |
michael@0 | 60 | var result2 = range3.compareBoundaryPoints(Range.START_TO_START, range1); |
michael@0 | 61 | } |
michael@0 | 62 | catch (ex) { |
michael@0 | 63 | var error = ex.name; |
michael@0 | 64 | var errorCode = ex.code; |
michael@0 | 65 | } |
michael@0 | 66 | |
michael@0 | 67 | ok(error == "WrongDocumentError", |
michael@0 | 68 | "The WrongDocumentError exception thrown when comparing ranges from " + |
michael@0 | 69 | "different documents "); |
michael@0 | 70 | ok(errorCode == DOMException.WRONG_DOCUMENT_ERR, |
michael@0 | 71 | "The exception thrown when comparing ranges from different documents " + |
michael@0 | 72 | "has the code DOMException.WRONG_DOCUMENT_ERR"); |
michael@0 | 73 | ok(result2 === undefined, "range1 and range3 couldn't be compared as expected."); |
michael@0 | 74 | SimpleTest.finish(); |
michael@0 | 75 | }); |
michael@0 | 76 | </script> |
michael@0 | 77 | </pre> |
michael@0 | 78 | </body> |
michael@0 | 79 | </html> |