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

Side by Side Diff: LayoutTests/http/tests/serviceworker/webexposed/resources/global-interface-listing-worker.js

Issue 1333853002: bindings: Moves event handlers and methods of Window to the instance object. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Synced. Created 5 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 /* Adopted from LayoutTests/webexposed/resources/global-interface-listing.js */ 1 /* Adopted from LayoutTests/webexposed/resources/global-interface-listing.js */
2 2
3 // Run all the code in a local scope.
4 (function(global_object) {
5
3 var globals = []; 6 var globals = [];
4 7
5 // List of builtin JS constructors; Blink is not controlling what properties the se 8 // List of builtin JS constructors; Blink is not controlling what properties the se
6 // objects have, so exercising them in a Blink test doesn't make sense. 9 // objects have, so exercising them in a Blink test doesn't make sense.
7 // 10 //
8 // This list should be kept in sync with the one at LayoutTests/webexposed/resou rces/global-interface-listing.js 11 // This list should be kept in sync with the one at LayoutTests/webexposed/resou rces/global-interface-listing.js
9 var js_builtins = new Set([ 12 var js_builtins = new Set([
10 'Array', 13 'Array',
11 'ArrayBuffer', 14 'ArrayBuffer',
12 'Boolean', 15 'Boolean',
13 'Date', 16 'Date',
14 'Error', 17 'Error',
15 'EvalError', 18 'EvalError',
16 'Float32Array', 19 'Float32Array',
17 'Float64Array', 20 'Float64Array',
18 'Function', 21 'Function',
22 'Infinity',
19 'Int16Array', 23 'Int16Array',
20 'Int32Array', 24 'Int32Array',
21 'Int8Array', 25 'Int8Array',
26 'Intl',
27 'JSON',
22 'Map', 28 'Map',
29 'Math',
30 'NaN',
23 'Number', 31 'Number',
24 'Object', 32 'Object',
25 'Promise', 33 'Promise',
26 'RangeError', 34 'RangeError',
27 'ReferenceError', 35 'ReferenceError',
28 'RegExp', 36 'RegExp',
29 'Set', 37 'Set',
30 'String', 38 'String',
31 'Symbol', 39 'Symbol',
32 'SyntaxError', 40 'SyntaxError',
33 'TypeError', 41 'TypeError',
42 'URIError',
34 'Uint16Array', 43 'Uint16Array',
35 'Uint32Array', 44 'Uint32Array',
36 'Uint8Array', 45 'Uint8Array',
37 'Uint8ClampedArray', 46 'Uint8ClampedArray',
38 'URIError',
39 'WeakMap', 47 'WeakMap',
40 'WeakSet', 48 'WeakSet',
49 'decodeURI',
50 'decodeURIComponent',
51 'encodeURI',
52 'encodeURIComponent',
53 'escape',
54 'eval',
55 'isFinite',
56 'isNaN',
57 'parseFloat',
58 'parseInt',
59 'undefined',
60 'unescape',
41 ]); 61 ]);
42 62
43 function is_web_idl_constructor(property_name) { 63 function is_web_idl_constructor(property_name) {
44 if (js_builtins.has(property_name)) 64 if (js_builtins.has(property_name))
45 return false; 65 return false;
46 var descriptor = Object.getOwnPropertyDescriptor(this, property_name); 66 var descriptor = Object.getOwnPropertyDescriptor(this, property_name);
47 if (descriptor.value === undefined || 67 if (descriptor.value === undefined ||
48 descriptor.value.prototype === undefined) { 68 descriptor.value.prototype === undefined) {
49 return false; 69 return false;
50 } 70 }
51 return descriptor.writable && !descriptor.enumerable && 71 return descriptor.writable && !descriptor.enumerable &&
52 descriptor.configurable; 72 descriptor.configurable;
53 } 73 }
54 74
55 var interface_names = Object.getOwnPropertyNames(this).filter(is_web_idl_constru ctor); 75 function collect_property_info(object, property_name, output) {
76 var descriptor = Object.getOwnPropertyDescriptor(object, property_name);
77 if ('value' in descriptor) {
78 var type;
79 if (typeof descriptor.value === 'function') {
80 type = 'method';
81 } else {
82 type = 'attribute';
83 }
84 output.push(' ' + type + ' ' + property_name);
85 } else {
86 if (descriptor.get)
87 output.push(' getter ' + property_name);
88 if (descriptor.set)
89 output.push(' setter ' + property_name);
90 }
91 }
92
93 var interface_names = Object.getOwnPropertyNames(global_object).filter(is_web_id l_constructor);
56 interface_names.sort(); 94 interface_names.sort();
57 interface_names.forEach(function(interface_name) { 95 interface_names.forEach(function(interface_name) {
58 globals.push('interface ' + interface_name); 96 globals.push('interface ' + interface_name);
59 var property_strings = []; 97 var property_strings = [];
60 var prototype = this[interface_name].prototype; 98 var prototype = this[interface_name].prototype;
61 Object.getOwnPropertyNames(prototype).forEach(function(property_name) { 99 Object.getOwnPropertyNames(prototype).forEach(function(property_name) {
62 var descriptor = Object.getOwnPropertyDescriptor( 100 collect_property_info(prototype, property_name, property_strings);
63 prototype, property_name); 101 });
64 if ('value' in descriptor) {
65 var type;
66 if (typeof descriptor.value === 'function') {
67 type = 'method';
68 } else {
69 type = 'attribute';
70 }
71 property_strings.push(' ' + type + ' ' + property_name);
72 } else {
73 if (descriptor.get)
74 property_strings.push(' getter ' + property_name);
75 if (descriptor.set)
76 property_strings.push(' setter ' + property_name);
77 }
78 });
79 globals.push.apply(globals, property_strings.sort()); 102 globals.push.apply(globals, property_strings.sort());
80 }); 103 });
81 104
105 globals.push('global object');
106 var property_strings = [];
107 var member_names = Object.getOwnPropertyNames(global_object).filter(function(pro perty_name) {
108 return !js_builtins.has(property_name) && !is_web_idl_constructor(property_nam e);
109 });
110 member_names.forEach(function(property_name) {
111 collect_property_info(global_object, property_name, property_strings);
112 });
113 globals.push.apply(globals, property_strings.sort());
114
82 self.addEventListener('message', function(event) { 115 self.addEventListener('message', function(event) {
83 event.ports[0].postMessage({ result: globals }); 116 event.ports[0].postMessage({ result: globals });
84 }); 117 });
118
119 })(this); // Run all the code in a local scope.
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698