test_dom_storage_event.html 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. <!DOCTYPE HTML>
  2. <html>
  3. <head>
  4. <title>Test for DOM StorageEvent</title>
  5. <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
  6. <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
  7. </head>
  8. <body>
  9. <p id="display"></p>
  10. <div id="content" style="display: none">
  11. </div>
  12. <pre id="test">
  13. <script type="application/javascript">
  14. const kTests = [
  15. { createEventArg: "StorageEvent",
  16. type: "aaa", bubbles: true, cancelable: true,
  17. key: null, oldValue: 'a', newValue: 'b', url: 'c', storageArea: null },
  18. { createEventArg: "storageevent",
  19. type: "bbb", bubbles: false, cancelable: true,
  20. key: 'key', oldValue: null, newValue: 'b', url: 'c', storageArea: null },
  21. { createEventArg: "Storageevent",
  22. type: "ccc", bubbles: true, cancelable: false,
  23. key: 'key', oldValue: 'a', newValue: null, url: 'c', storageArea: null },
  24. { createEventArg: "storageEvent",
  25. type: "ddd", bubbles: false, cancelable: false,
  26. key: 'key', oldValue: 'a', newValue: 'b', url: null, storageArea: null },
  27. { createEventArg: "StorageEvent",
  28. type: "eee", bubbles: true, cancelable: true,
  29. key: 'key', oldValue: 'a', newValue: 'b', url: 'c', storageArea: null },
  30. { createEventArg: "storageevent",
  31. type: "fff", bubbles: false, cancelable: true,
  32. key: null, oldValue: null, newValue: null, url: null, storageArea: null },
  33. ];
  34. for (var i = 0; i < kTests.length; i++) {
  35. var description = "test, Index: " + i + ", ";
  36. const kTest = kTests[i];
  37. var e = document.createEvent(kTest.createEventArg);
  38. e.initStorageEvent(kTest.type, kTest.bubbles, kTest.cancelable,
  39. kTest.key, kTest.oldValue, kTest.newValue, kTest.url,
  40. kTest.storageArea);
  41. for (var attr in kTest) {
  42. if (attr == 'createEventArg')
  43. continue;
  44. is(e[attr], kTest[attr], description + attr + " returns wrong value");
  45. }
  46. is(e.isTrusted, false, description + "isTrusted returns wrong value");
  47. }
  48. </script>
  49. </pre>
  50. </body>
  51. </html>