content/test/unit/test_xml_parser.js

Sat, 03 Jan 2015 20:18:00 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Sat, 03 Jan 2015 20:18:00 +0100
branch
TOR_BUG_3246
changeset 7
129ffea94266
permissions
-rw-r--r--

Conditionally enable double key logic according to:
private browsing mode or privacy.thirdparty.isolate preference and
implement in GetCookieStringCommon and FindCookie where it counts...
With some reservations of how to convince FindCookie users to test
condition and pass a nullptr when disabling double key logic.

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

mercurial