test_bug658746.html (2262B)
1 <!DOCTYPE HTML> 2 <html> 3 <!-- 4 https://bugzilla.mozilla.org/show_bug.cgi?id=658746 5 --> 6 <head> 7 <title>Test for Bug 658746</title> 8 <script src="/tests/SimpleTest/SimpleTest.js"></script> 9 <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/> 10 </head> 11 <body> 12 <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=658746">Mozilla Bug 658746</a> 13 <p id="display"></p> 14 <div id="content" style="display: none"> 15 16 </div> 17 <pre id="test"> 18 <script type="application/javascript"> 19 20 /** Test for Bug 658746 */ 21 22 /** 23 * Sets property, gets property and deletes property. 24 */ 25 function SetGetDelete(prop) 26 { 27 var el = document.createElement('div'); 28 29 el.dataset[prop] = 'aaaaaa'; 30 is(el.dataset[prop], 'aaaaaa', 'Dataset property "' + prop + '" should have been set.'); 31 32 delete el.dataset[prop]; 33 is(el.dataset[prop], undefined, 'Dataset property"' + prop + '" should have been deleted.'); 34 } 35 36 /** 37 * Gets, deletes and sets property. Expects exception while trying to set property. 38 */ 39 function SetExpectException(prop) 40 { 41 var el = document.createElement('div'); 42 43 is(el.dataset[prop], undefined, 'Dataset property "' + prop + '" should be undefined.'); 44 delete el.dataset[prop]; 45 46 try { 47 el.dataset[prop] = "xxxxxx"; 48 ok(false, 'Exception should have been thrown when setting "' + prop + '".'); 49 } catch (ex) { 50 ok(true, 'Exception should have been thrown.'); 51 } 52 } 53 54 // Numbers as properties. 55 SetGetDelete(-12345678901234567000); 56 SetGetDelete(-1); 57 SetGetDelete(0); 58 SetGetDelete(1); 59 SetGetDelete(12345678901234567000); 60 61 // Floating point numbers as properties. 62 SetGetDelete(-1.1); 63 SetGetDelete(0.0); 64 SetGetDelete(1.1); 65 66 // Hexadecimal numbers as properties. 67 SetGetDelete(0x3); 68 SetGetDelete(0xa); 69 70 // Octal numbers as properties. 71 SetGetDelete(0o3); 72 SetGetDelete(0o7); 73 74 // String numbers as properties. 75 SetGetDelete('0'); 76 SetGetDelete('01'); 77 SetGetDelete('0x1'); 78 79 // Undefined as property. 80 SetGetDelete(undefined); 81 82 // Empty arrays as properties. 83 SetGetDelete(new Array()); 84 SetGetDelete([]); 85 86 // Non-empty array and object as properties. 87 SetExpectException(['a', 'b']); 88 SetExpectException({'a':'b'}); 89 90 // Objects as properties. 91 SetExpectException(new Object()); 92 SetExpectException(document); 93 94 </script> 95 </pre> 96 </body> 97 </html>