Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(89)

Side by Side Diff: LayoutTests/fast/dom/custom/resources/document-register-fuzz.js

Issue 23717043: Implement Custom Elements 'extends' option. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 7 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 1
2 function setupObjectHooks(hooks) 2 function setupObjectHooks(hooks)
3 { 3 {
4 // Wrapper for these object should be materialized before setting hooks. 4 // Wrapper for these object should be materialized before setting hooks.
5 console.log; 5 console.log;
6 document.register 6 document.register;
7 HTMLSpanElement.prototype; 7 HTMLSpanElement.prototype;
8 8
9 Object.defineProperty(Object.prototype, "prototype", { 9 Object.defineProperty(Object.prototype, "prototype", {
10 get: function() { return hooks.prototypeGet(); }, 10 get: function() { return hooks.prototypeGet(); },
11 set: function(value) { return hooks.prototypeSet(value); } 11 set: function(value) { return hooks.prototypeSet(value); }
12 }); 12 });
13 13
14 Object.defineProperty(Object.prototype, "constructor", { 14 Object.defineProperty(Object.prototype, "constructor", {
15 get: function() { return hooks.constructorGet(); }, 15 get: function() { return hooks.constructorGet(); },
16 set: function(value) { return hooks.constructorSet(value); } 16 set: function(value) { return hooks.constructorSet(value); }
17 }); 17 });
18 18
19 return hooks; 19 return hooks;
20 } 20 }
21 21
22 function exerciseDocumentRegister() 22 function exerciseDocumentRegister()
23 { 23 {
24 register('x-a', {});
25 register('x-b', {prototype: Object.create(HTMLElement.prototype)});
26 }
27
28 function register(name, options)
29 {
24 var myConstructor = null; 30 var myConstructor = null;
25 var myPrototype = Object.create(HTMLElement.prototype);
26 try { 31 try {
27 myConstructor = document.register("x-do-nothing", { prototype: myPrototy pe }); 32 myConstructor = document.register(name, options);
28 } catch (e) { } 33 } catch (e) { }
29 34
30 try { 35 try {
31 if (!myConstructor) { 36 if (!myConstructor) {
32 debug("Constructor object isn't created."); 37 debug("Constructor object isn't created.");
33 return; 38 return;
34 } 39 }
35 40
36 if (myConstructor.prototype != myPrototype) { 41 if (myConstructor.prototype != options.prototype) {
37 console.log("FAIL: bad prototype"); 42 console.log("FAIL: bad prototype");
38 return; 43 return;
39 } 44 }
40 45
41 var element = new myConstructor(); 46 var element = new myConstructor();
42 if (!element) 47 if (!element)
43 return; 48 return;
44 if (element.constructor != myConstructor) { 49 if (element.constructor != myConstructor) {
45 console.log("FAIL: bad constructor"); 50 console.log("FAIL: bad constructor");
46 return; 51 return;
47 } 52 }
48 } catch (e) { console.log(e); } 53 } catch (e) { console.log(e); }
49 } 54 }
OLDNEW
« no previous file with comments | « LayoutTests/fast/dom/custom/lifecycle-created-paste.html ('k') | LayoutTests/fast/dom/custom/type-extensions.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698