| <head> |
| <script src="../../../resources/testharness.js"></script> |
| <script src="../../../resources/testharnessreport.js"></script> |
| </head> |
| <body> |
| <script> |
| localStorage.clear(); |
| |
| test(() => { |
| assert_array_equals(Object.getOwnPropertyNames(localStorage), []); |
| }, "Object.getOwnPropertyNames(localStorage) on an empty local storage should return an empty array."); |
| |
| test(() => { |
| Object.defineProperty(localStorage, '1', {value: 'present'}); |
| assert_equals(localStorage.getItem('1'), 'present'); |
| assert_array_equals(Object.getOwnPropertyNames(localStorage), ['1']); |
| }, "Object.defineProperty can be used to add items to localStorage."); |
| |
| test(() => { |
| assert_equals(delete localStorage[1], true); |
| assert_array_equals(Object.getOwnPropertyNames(localStorage), []); |
| }, "Operator delete can be used to remove items from localStorage."); |
| |
| test(() => { |
| Object.defineProperty(localStorage, '2', {value: 'present', configurable: false}); |
| assert_equals(localStorage.getItem('2'), 'present'); |
| assert_array_equals(Object.getOwnPropertyNames(localStorage), ['2']); |
| |
| assert_equals(delete localStorage[2], true); |
| assert_array_equals(Object.getOwnPropertyNames(localStorage), []); |
| }, "The configurable modifier does effect the result when used in adding properties to localStorage with Object.defineProperty."); |
| |
| </script> |
| </body> |