content/test/unit/test_xml_parser.js

Tue, 06 Jan 2015 21:39:09 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Tue, 06 Jan 2015 21:39:09 +0100
branch
TOR_BUG_9701
changeset 8
97036ab72558
permissions
-rw-r--r--

Conditionally force memory storage according to privacy.thirdparty.isolate;
This solves Tor bug #9701, complying with disk avoidance documented in
https://www.torproject.org/projects/torbrowser/design/#disk-avoidance.

michael@0 1 function run_test () {
michael@0 2 for (var i = 0; i < tests.length && tests[i][0]; ++i) {
michael@0 3 if (!tests[i][0].call()) {
michael@0 4 do_throw(tests[i][1]);
michael@0 5 }
michael@0 6 }
michael@0 7 }
michael@0 8
michael@0 9 var tests = [
michael@0 10 [ test1, "Unable to parse basic XML document" ],
michael@0 11 [ test2, "ParseXML doesn't return nsIDOMDocument" ],
michael@0 12 [ test3, "ParseXML return value's documentElement is not nsIDOMElement" ],
michael@0 13 [ test4, "" ],
michael@0 14 [ test5, "" ],
michael@0 15 [ test6, "" ],
michael@0 16 [ null ]
michael@0 17 ];
michael@0 18
michael@0 19 function test1() {
michael@0 20 return ParseXML("<root/>");
michael@0 21 }
michael@0 22
michael@0 23 function test2() {
michael@0 24 return (ParseXML("<root/>") instanceof nsIDOMDocument);
michael@0 25 }
michael@0 26
michael@0 27 function test3() {
michael@0 28 return (ParseXML("<root/>").documentElement instanceof nsIDOMElement);
michael@0 29 }
michael@0 30
michael@0 31 function test4() {
michael@0 32 var doc = ParseXML("<root/>");
michael@0 33 do_check_eq(doc.documentElement.namespaceURI, null);
michael@0 34 return true;
michael@0 35 }
michael@0 36
michael@0 37 function test5() {
michael@0 38 var doc = ParseXML("<root xmlns=''/>");
michael@0 39 do_check_eq(doc.documentElement.namespaceURI, null);
michael@0 40 return true;
michael@0 41 }
michael@0 42
michael@0 43 function test6() {
michael@0 44 var doc = ParseXML("<root xmlns='ns1'/>");
michael@0 45 do_check_neq(doc.documentElement.namespaceURI, null);
michael@0 46 do_check_eq(doc.documentElement.namespaceURI, 'ns1');
michael@0 47 return true;
michael@0 48 }

mercurial