localstorage-value-truncation.html 1.3 KB

12345678910111213141516171819202122232425262728293031
  1. <html>
  2. <body>
  3. <p>In this test we need to find out if the browser can save the localStorage item correctly without truncated by the \x00 in the middle of the string.</p>
  4. <script type="text/javascript">
  5. var key = 'TruncVal';
  6. var value = '123\x00567';
  7. var x = localStorage.getItem(key);
  8. if (!x) {
  9. localStorage.setItem(key, value);
  10. document.write("<p>It hasn't got the '" + key + "' in the localStorage database, will create it using:<br>");
  11. document.write("<code>localStorage.setItem('" + key + "', '" + value + "');</code><br>");
  12. document.write("Now close your browser and start it again to see the results.</p>");
  13. }
  14. else {
  15. document.write("<p>The value of " + key + " is: '" + x + "', the length is: " + x.length + "<br>");
  16. if (x == value) {
  17. document.write("PASS.");
  18. }
  19. else {
  20. document.write("FAIL: The expected value is: '" + value + "', the expected length is: " + value.length);
  21. }
  22. document.write("</p><a href=\"javascript:localStorage.removeItem('" + key + "');\">remove '" + key + "' from localStorage</a>");
  23. }
  24. </script>
  25. <p>This is for <a href="https://bugs.webkit.org/show_bug.cgi?id=58762">https://bugs.webkit.org/show_bug.cgi?id=58762</a>
  26. </p>
  27. </body>
  28. </html>