test_usvstring.html (1706B)
1 <!-- Any copyright is dedicated to the Public Domain. 2 - http://creativecommons.org/publicdomain/zero/1.0/ --> 3 <!DOCTYPE HTML> 4 <html> 5 <head> 6 <title>Test USVString</title> 7 <script src="/tests/SimpleTest/SimpleTest.js"></script> 8 <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" /> 9 </head> 10 <body> 11 <script class="testbody" type="application/javascript"> 12 /* global TestInterfaceJS */ 13 14 SimpleTest.waitForExplicitFinish(); 15 SpecialPowers.pushPrefEnv({set: [["dom.expose_test_interfaces", true]]}, function() { 16 var testInterfaceJS = new TestInterfaceJS(); 17 ok(testInterfaceJS, "got a TestInterfaceJS object"); 18 // For expected values, see algorithm definition here: 19 // http://heycam.github.io/webidl/#dfn-obtain-unicode 20 var testList = [ 21 { string: "foo", 22 expected: "foo" }, 23 { string: "This is U+2070E: \ud841\udf0e", 24 expected: "This is U+2070E: \ud841\udf0e" }, 25 { string: "Missing low surrogate: \ud841", 26 expected: "Missing low surrogate: \ufffd" }, 27 { string: "Missing low surrogate with trailer: \ud841!!", 28 expected: "Missing low surrogate with trailer: \ufffd!!" }, 29 { string: "Missing high surrogate: \udf0e", 30 expected: "Missing high surrogate: \ufffd" }, 31 { string: "Missing high surrogate with trailer: \udf0e!!", 32 expected: "Missing high surrogate with trailer: \ufffd!!" }, 33 { string: "U+2070E after malformed: \udf0e\ud841\udf0e", 34 expected: "U+2070E after malformed: \ufffd\ud841\udf0e" }, 35 ]; 36 testList.forEach(function(test) { 37 is(testInterfaceJS.convertSVS(test.string), test.expected, "Convert '" + test.string + "'"); 38 }); 39 SimpleTest.finish(); 40 }); 41 </script> 42 </body> 43 </html>