Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / third_party / WebKit / LayoutTests / fast / dom / custom / resources / document-register-fuzz.js
blobdb4ba33edd6b8064119f3dd71cc12e6cc795df0d
2 function setupObjectHooks(hooks)
4 // Wrapper for these object should be materialized before setting hooks.
5 console.log;
6 document.register;
7 HTMLSpanElement.prototype;
9 Object.defineProperty(Object.prototype, "prototype", {
10 get: function() { return hooks.prototypeGet(); },
11 set: function(value) { return hooks.prototypeSet(value); }
12 });
14 Object.defineProperty(Object.prototype, "constructor", {
15 get: function() { return hooks.constructorGet(); },
16 set: function(value) { return hooks.constructorSet(value); }
17 });
19 return hooks;
22 function exerciseDocumentRegister()
24 register('x-a', {});
25 register('x-b', {prototype: Object.create(HTMLElement.prototype)});
28 function register(name, options)
30 var myConstructor = null;
31 try {
32 myConstructor = document.registerElement(name, options);
33 } catch (e) { }
35 try {
36 if (!myConstructor) {
37 debug("Constructor object isn't created.");
38 return;
41 if (options.prototype !== undefined && myConstructor.prototype != options.prototype) {
42 console.log("FAIL: bad prototype");
43 return;
46 var element = new myConstructor();
47 if (!element)
48 return;
49 if (element.constructor != myConstructor) {
50 console.log("FAIL: bad constructor");
51 return;
53 } catch (e) { console.log(e); }