tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

Document-createProcessingInstruction.js (1242B)


      1 test(function() {
      2  var invalid = [
      3        ["A", "?>"],
      4        ["\u00B7A", "x"],
      5        ["\u00D7A", "x"],
      6        ["A\u00D7", "x"],
      7        ["\\A", "x"],
      8        ["\f", "x"],
      9        [0, "x"],
     10        ["0", "x"]
     11      ],
     12      valid = [
     13        ["xml:fail", "x"],
     14        ["A\u00B7A", "x"],
     15        ["a0", "x"]
     16      ]
     17 
     18  for (var i = 0, il = invalid.length; i < il; i++) {
     19    test(function() {
     20      assert_throws_dom("INVALID_CHARACTER_ERR", function() {
     21        document.createProcessingInstruction(invalid[i][0], invalid[i][1])
     22      })
     23    }, "Should throw an INVALID_CHARACTER_ERR for target " +
     24       format_value(invalid[i][0]) + " and data " +
     25       format_value(invalid[i][1]) + ".")
     26  }
     27  for (var i = 0, il = valid.length; i < il; ++i) {
     28    test(function() {
     29      var pi = document.createProcessingInstruction(valid[i][0], valid[i][1]);
     30      assert_equals(pi.target, valid[i][0]);
     31      assert_equals(pi.data, valid[i][1]);
     32      assert_equals(pi.ownerDocument, document);
     33      assert_true(pi instanceof ProcessingInstruction);
     34      assert_true(pi instanceof Node);
     35    }, "Should get a ProcessingInstruction for target " +
     36      format_value(valid[i][0]) + " and data " +
     37      format_value(valid[i][1]) + ".")
     38  }
     39 })