| OLD | NEW |
| (Empty) |
| 1 <script> | |
| 2 function setupObjectHooks(hooks) | |
| 3 { | |
| 4 // Wrapper for these object should be materialized before setting hooks. | |
| 5 console.log; | |
| 6 document.register; | |
| 7 | |
| 8 Object.defineProperty(Object.prototype, "prototype", { | |
| 9 get: function() { return hooks.prototypeGet(); }, | |
| 10 set: function(value) { return hooks.prototypeSet(value); } | |
| 11 }); | |
| 12 | |
| 13 Object.defineProperty(Object.prototype, "constructor", { | |
| 14 get: function() { return hooks.constructorGet(); }, | |
| 15 set: function(value) { return hooks.constructorSet(value); } | |
| 16 }); | |
| 17 | |
| 18 return hooks; | |
| 19 } | |
| 20 | |
| 21 function exerciseDocumentRegister() | |
| 22 { | |
| 23 register('x-a', {}); | |
| 24 register('x-b', {prototype: Object.create(HTMLElement.prototype)}); | |
| 25 } | |
| 26 | |
| 27 function register(name, options) | |
| 28 { | |
| 29 var myConstructor = null; | |
| 30 try { | |
| 31 myConstructor = document.registerElement(name, options); | |
| 32 } catch (e) { } | |
| 33 | |
| 34 try { | |
| 35 if (!myConstructor) { | |
| 36 console.log("Constructor object isn't created."); | |
| 37 return; | |
| 38 } | |
| 39 | |
| 40 if (myConstructor.prototype != options.prototype) { | |
| 41 console.log("FAIL: bad prototype"); | |
| 42 return; | |
| 43 } | |
| 44 | |
| 45 var element = new myConstructor(); | |
| 46 if (!element) | |
| 47 return; | |
| 48 if (element.constructor != myConstructor) { | |
| 49 console.log("FAIL: bad constructor"); | |
| 50 return; | |
| 51 } | |
| 52 } catch (e) { console.log(e); } | |
| 53 } | |
| 54 | |
| 55 this.exports = { | |
| 56 setupObjectHooks: setupObjectHooks, | |
| 57 exerciseDocumentRegister: exerciseDocumentRegister, | |
| 58 register: register, | |
| 59 } | |
| 60 </script> | |
| OLD | NEW |