Thu, 22 Jan 2015 13:21:57 +0100
Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6
michael@0 | 1 | <html xmlns="http://www.w3.org/1999/xhtml"> |
michael@0 | 2 | <head> |
michael@0 | 3 | <title>incomplete UTF-16 test</title> |
michael@0 | 4 | <meta http-equiv="Content-type" content="text/html; charset=UTF-8" /> |
michael@0 | 5 | |
michael@0 | 6 | <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script> |
michael@0 | 7 | <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" /> |
michael@0 | 8 | |
michael@0 | 9 | <script type="text/javascript"> |
michael@0 | 10 | |
michael@0 | 11 | function startTest() |
michael@0 | 12 | { |
michael@0 | 13 | // Check this works for a diacritics |
michael@0 | 14 | var k = "valid UTF-16 key"; |
michael@0 | 15 | var v = "ěščřžýáíéúůĚŠČŘŽÝÁÍÉÚŮ"; |
michael@0 | 16 | |
michael@0 | 17 | localStorage.setItem(k, v); |
michael@0 | 18 | is(localStorage.getItem(k), v, "UTF-16 value results from getItem"); |
michael@0 | 19 | |
michael@0 | 20 | localStorage.setItem(v, "a value"); |
michael@0 | 21 | is(localStorage.getItem(v), "a value", "value result using UTF-16 key from getItem"); |
michael@0 | 22 | |
michael@0 | 23 | localStorage.clear(); |
michael@0 | 24 | |
michael@0 | 25 | localStorage[k] = v; |
michael@0 | 26 | is(localStorage[k], v, "UTF-16 value results from []"); |
michael@0 | 27 | |
michael@0 | 28 | localStorage[v] = "a value"; |
michael@0 | 29 | is(localStorage[v], "a value", "value result using UTF-16 key from []"); |
michael@0 | 30 | |
michael@0 | 31 | localStorage.clear(); |
michael@0 | 32 | |
michael@0 | 33 | localStorage.aKey = v; |
michael@0 | 34 | is(localStorage.aKey, v, "UTF-16 value results from a dynamic property"); |
michael@0 | 35 | |
michael@0 | 36 | localStorage.clear(); |
michael@0 | 37 | |
michael@0 | 38 | // Broken UTF-16 |
michael@0 | 39 | k = "broken UTF-16 key"; |
michael@0 | 40 | v = "\uD800"; // broken UTF-16 |
michael@0 | 41 | |
michael@0 | 42 | localStorage.setItem(k, v); |
michael@0 | 43 | is(localStorage.getItem(k), v, "broken value results from getItem"); |
michael@0 | 44 | |
michael@0 | 45 | localStorage.setItem(v, "a value"); |
michael@0 | 46 | is(localStorage.getItem(v), "a value", "value result using broken key from getItem"); |
michael@0 | 47 | |
michael@0 | 48 | localStorage.clear(); |
michael@0 | 49 | |
michael@0 | 50 | localStorage[k] = v; |
michael@0 | 51 | is(localStorage[k], v, "broken value results from []"); |
michael@0 | 52 | |
michael@0 | 53 | localStorage[v] = "a value"; |
michael@0 | 54 | is(localStorage[v], "a value", "value result using broken key from []"); |
michael@0 | 55 | |
michael@0 | 56 | localStorage.clear(); |
michael@0 | 57 | |
michael@0 | 58 | localStorage.aKey = v; |
michael@0 | 59 | is(localStorage.aKey, v, "broken value results from a dynamic property"); |
michael@0 | 60 | |
michael@0 | 61 | localStorage.clear(); |
michael@0 | 62 | |
michael@0 | 63 | // Another variant |
michael@0 | 64 | v = "FcK" |
michael@0 | 65 | + String.fromCharCode(0x8a) |
michael@0 | 66 | + ".jp"; |
michael@0 | 67 | |
michael@0 | 68 | localStorage.setItem(k, v); |
michael@0 | 69 | is(localStorage.getItem(k), v); |
michael@0 | 70 | |
michael@0 | 71 | localStorage.setItem(v, "a value"); |
michael@0 | 72 | is(localStorage.getItem(v), "a value"); |
michael@0 | 73 | |
michael@0 | 74 | localStorage.clear(); |
michael@0 | 75 | |
michael@0 | 76 | // And yet another variant |
michael@0 | 77 | v = "something" |
michael@0 | 78 | + String.fromCharCode(355, 277, 349, 357, 533, 537, 101, 345); |
michael@0 | 79 | |
michael@0 | 80 | localStorage.setItem(k, v); |
michael@0 | 81 | is(localStorage.getItem(k), v); |
michael@0 | 82 | |
michael@0 | 83 | localStorage.setItem(v, "a value"); |
michael@0 | 84 | is(localStorage.getItem(v), "a value"); |
michael@0 | 85 | |
michael@0 | 86 | localStorage.clear(); |
michael@0 | 87 | |
michael@0 | 88 | SimpleTest.finish(); |
michael@0 | 89 | } |
michael@0 | 90 | |
michael@0 | 91 | SimpleTest.waitForExplicitFinish(); |
michael@0 | 92 | |
michael@0 | 93 | </script> |
michael@0 | 94 | |
michael@0 | 95 | </head> |
michael@0 | 96 | |
michael@0 | 97 | <body onload="startTest();"> |
michael@0 | 98 | |
michael@0 | 99 | </body> |
michael@0 | 100 | </html> |