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

Side by Side Diff: third_party/WebKit/LayoutTests/webexposed/resources/global-interface-listing.js

Issue 1360233007: bindings: Moves event handlers and methods of Window to the instance object. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 2 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
OLDNEW
1 // Run all the code in a local scope.
2 (function(globalObject) {
3
4 // Save the list of property names of the global object before loading other scr ipts.
5 var propertyNamesInGlobal = globalObject.propertyNamesInGlobal || Object.getOwnP ropertyNames(globalObject);
6
1 if (self.importScripts) { 7 if (self.importScripts) {
2 importScripts('../../resources/js-test.js'); 8 importScripts('../../resources/js-test.js');
3 9
4 if (!self.postMessage) { 10 if (!self.postMessage) {
5 // Shared worker. Make postMessage send to the newest client, which in 11 // Shared worker. Make postMessage send to the newest client, which in
6 // our tests is the only client. 12 // our tests is the only client.
7 13
8 // Store messages for sending until we have somewhere to send them. 14 // Store messages for sending until we have somewhere to send them.
9 self.postMessage = function(message) { 15 self.postMessage = function(message) {
10 if (typeof self.pendingMessages === "undefined") 16 if (typeof self.pendingMessages === "undefined")
(...skipping 21 matching lines...) Expand all
32 var jsBuiltins = new Set([ 38 var jsBuiltins = new Set([
33 'Array', 39 'Array',
34 'ArrayBuffer', 40 'ArrayBuffer',
35 'Boolean', 41 'Boolean',
36 'Date', 42 'Date',
37 'Error', 43 'Error',
38 'EvalError', 44 'EvalError',
39 'Float32Array', 45 'Float32Array',
40 'Float64Array', 46 'Float64Array',
41 'Function', 47 'Function',
48 'Infinity',
42 'Int16Array', 49 'Int16Array',
43 'Int32Array', 50 'Int32Array',
44 'Int8Array', 51 'Int8Array',
52 'Intl',
53 'JSON',
45 'Map', 54 'Map',
55 'Math',
56 'NaN',
46 'Number', 57 'Number',
47 'Object', 58 'Object',
48 'Promise', 59 'Promise',
49 'RangeError', 60 'RangeError',
50 'ReferenceError', 61 'ReferenceError',
51 'RegExp', 62 'RegExp',
52 'Set', 63 'Set',
53 'String', 64 'String',
54 'Symbol', 65 'Symbol',
55 'SyntaxError', 66 'SyntaxError',
56 'TypeError', 67 'TypeError',
68 'URIError',
57 'Uint16Array', 69 'Uint16Array',
58 'Uint32Array', 70 'Uint32Array',
59 'Uint8Array', 71 'Uint8Array',
60 'Uint8ClampedArray', 72 'Uint8ClampedArray',
61 'URIError',
62 'WeakMap', 73 'WeakMap',
63 'WeakSet', 74 'WeakSet',
75 'decodeURI',
76 'decodeURIComponent',
77 'encodeURI',
78 'encodeURIComponent',
79 'escape',
80 'eval',
81 'isFinite',
82 'isNaN',
83 'parseFloat',
84 'parseInt',
85 'undefined',
86 'unescape',
64 ]); 87 ]);
65 88
66 function isWebIDLConstructor(propertyName) { 89 function isWebIDLConstructor(propertyName) {
67 if (jsBuiltins.has(propertyName)) 90 if (jsBuiltins.has(propertyName))
68 return false; 91 return false;
69 var descriptor = Object.getOwnPropertyDescriptor(this, propertyName); 92 var descriptor = Object.getOwnPropertyDescriptor(this, propertyName);
70 if (descriptor.value == undefined || descriptor.value.prototype == undefined ) 93 if (descriptor.value == undefined || descriptor.value.prototype == undefined )
71 return false; 94 return false;
72 return descriptor.writable && !descriptor.enumerable && descriptor.configura ble; 95 return descriptor.writable && !descriptor.enumerable && descriptor.configura ble;
73 } 96 }
74 97
98 function collectPropertyInfo(object, propertyName, output) {
99 var descriptor = Object.getOwnPropertyDescriptor(object, propertyName);
100 if ('value' in descriptor) {
101 var type = typeof descriptor.value === 'function' ? 'method' : 'attribut e';
102 output.push(' ' + type + ' ' + propertyName);
103 } else {
104 if (descriptor.get)
105 output.push(' getter ' + propertyName);
106 if (descriptor.set)
107 output.push(' setter ' + propertyName);
108 }
109 }
110
75 // FIXME: List interfaces with NoInterfaceObject specified in their IDL file. 111 // FIXME: List interfaces with NoInterfaceObject specified in their IDL file.
76 debug('[INTERFACES]') 112 debug('[INTERFACES]');
77 var interfaceNames = Object.getOwnPropertyNames(this).filter(isWebIDLConstructor ); 113 var interfaceNames = Object.getOwnPropertyNames(this).filter(isWebIDLConstructor );
78 interfaceNames.sort(); 114 interfaceNames.sort();
79 interfaceNames.forEach(function(interfaceName) { 115 interfaceNames.forEach(function(interfaceName) {
80 debug('interface ' + interfaceName); 116 debug('interface ' + interfaceName);
81 var propertyStrings = []; 117 var propertyStrings = [];
82 var prototype = this[interfaceName].prototype; 118 var prototype = this[interfaceName].prototype;
83 Object.getOwnPropertyNames(prototype).forEach(function(propertyName) { 119 Object.getOwnPropertyNames(prototype).forEach(function(propertyName) {
84 var descriptor = Object.getOwnPropertyDescriptor(prototype, propertyName ); 120 collectPropertyInfo(prototype, propertyName, propertyStrings);
85 if ('value' in descriptor) {
86 var type = typeof descriptor.value === 'function' ? 'method' : 'attr ibute';
87 propertyStrings.push(' ' + type + ' ' + propertyName);
88 } else {
89 if (descriptor.get)
90 propertyStrings.push(' getter ' + propertyName);
91 if (descriptor.set)
92 propertyStrings.push(' setter ' + propertyName);
93 }
94 }); 121 });
95 propertyStrings.sort().forEach(debug); 122 propertyStrings.sort().forEach(debug);
96 }); 123 });
97 124
125 debug('[GLOBAL OBJECT]');
126 var propertyStrings = [];
127 var memberNames = propertyNamesInGlobal.filter(function(propertyName) {
128 return !jsBuiltins.has(propertyName) && !isWebIDLConstructor(propertyName);
129 });
130 memberNames.forEach(function(propertyName) {
131 collectPropertyInfo(globalObject, propertyName, propertyStrings);
132 });
133 propertyStrings.sort().forEach(debug);
134
98 if (isWorker()) 135 if (isWorker())
99 finishJSTest(); 136 finishJSTest();
137
138 })(this); // Run all the code in a local scope.
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698