OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2014 Google Inc. All rights reserved. | 2 * Copyright (C) 2014 Google Inc. All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
6 * met: | 6 * met: |
7 * | 7 * |
8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
90 if (xhr.readyState !== XMLHttpRequest.DONE) | 90 if (xhr.readyState !== XMLHttpRequest.DONE) |
91 return; | 91 return; |
92 | 92 |
93 if ([0, 200, 304].indexOf(xhr.status) === -1) // Testing harness fi
le:/// results in 0. | 93 if ([0, 200, 304].indexOf(xhr.status) === -1) // Testing harness fi
le:/// results in 0. |
94 reject(new Error("While loading from url " + url + " server resp
onded with a status of " + xhr.status)); | 94 reject(new Error("While loading from url " + url + " server resp
onded with a status of " + xhr.status)); |
95 else | 95 else |
96 fulfill(e.target.response); | 96 fulfill(e.target.response); |
97 } | 97 } |
98 xhr.send(null); | 98 xhr.send(null); |
99 } | 99 } |
100 } | 100 }; |
101 | 101 |
102 /** | 102 /** |
103 * http://tools.ietf.org/html/rfc3986#section-5.2.4 | 103 * http://tools.ietf.org/html/rfc3986#section-5.2.4 |
104 * @param {string} path | 104 * @param {string} path |
105 * @return {string} | 105 * @return {string} |
106 */ | 106 */ |
107 Runtime.normalizePath = function(path) | 107 Runtime.normalizePath = function(path) |
108 { | 108 { |
109 if (path.indexOf("..") === -1 && path.indexOf(".") === -1) | 109 if (path.indexOf("..") === -1 && path.indexOf(".") === -1) |
110 return path; | 110 return path; |
(...skipping 11 matching lines...) Expand all Loading... |
122 } | 122 } |
123 var normalizedPath = normalizedSegments.join("/"); | 123 var normalizedPath = normalizedSegments.join("/"); |
124 if (normalizedPath[normalizedPath.length - 1] === "/") | 124 if (normalizedPath[normalizedPath.length - 1] === "/") |
125 return normalizedPath; | 125 return normalizedPath; |
126 if (path[0] === "/" && normalizedPath) | 126 if (path[0] === "/" && normalizedPath) |
127 normalizedPath = "/" + normalizedPath; | 127 normalizedPath = "/" + normalizedPath; |
128 if ((path[path.length - 1] === "/") || (segments[segments.length - 1] === ".
") || (segments[segments.length - 1] === "..")) | 128 if ((path[path.length - 1] === "/") || (segments[segments.length - 1] === ".
") || (segments[segments.length - 1] === "..")) |
129 normalizedPath = normalizedPath + "/"; | 129 normalizedPath = normalizedPath + "/"; |
130 | 130 |
131 return normalizedPath; | 131 return normalizedPath; |
132 } | 132 }; |
133 | 133 |
134 /** | 134 /** |
135 * @param {!Array.<string>} scriptNames | 135 * @param {!Array.<string>} scriptNames |
136 * @param {string=} base | 136 * @param {string=} base |
137 * @return {!Promise.<undefined>} | 137 * @return {!Promise.<undefined>} |
138 */ | 138 */ |
139 Runtime._loadScriptsPromise = function(scriptNames, base) | 139 Runtime._loadScriptsPromise = function(scriptNames, base) |
140 { | 140 { |
141 /** @type {!Array<!Promise<undefined>>} */ | 141 /** @type {!Array<!Promise<undefined>>} */ |
142 var promises = []; | 142 var promises = []; |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
182 function evaluateScript(sourceURL, scriptSource) | 182 function evaluateScript(sourceURL, scriptSource) |
183 { | 183 { |
184 _loadedScripts[sourceURL] = true; | 184 _loadedScripts[sourceURL] = true; |
185 if (!scriptSource) { | 185 if (!scriptSource) { |
186 // Do not reject, as this is normal in the hosted mode. | 186 // Do not reject, as this is normal in the hosted mode. |
187 console.error("Empty response arrived for script '" + sourceURL + "'
"); | 187 console.error("Empty response arrived for script '" + sourceURL + "'
"); |
188 return; | 188 return; |
189 } | 189 } |
190 self.eval(scriptSource + "\n//# sourceURL=" + sourceURL); | 190 self.eval(scriptSource + "\n//# sourceURL=" + sourceURL); |
191 } | 191 } |
192 } | 192 }; |
193 | 193 |
194 /** | 194 /** |
195 * @type {!Object.<string, string>} | 195 * @type {!Object.<string, string>} |
196 */ | 196 */ |
197 Runtime._queryParamsObject = { __proto__: null }; | 197 Runtime._queryParamsObject = { __proto__: null }; |
198 | 198 |
199 Runtime._instanceSymbol = Symbol("instance"); | 199 Runtime._instanceSymbol = Symbol("instance"); |
200 Runtime._extensionSymbol = Symbol("extension"); | 200 Runtime._extensionSymbol = Symbol("extension"); |
201 | 201 |
202 /** | 202 /** |
(...skipping 16 matching lines...) Expand all Loading... |
219 */ | 219 */ |
220 function cacheResource(path, content) | 220 function cacheResource(path, content) |
221 { | 221 { |
222 if (!content) { | 222 if (!content) { |
223 console.error("Failed to load resource: " + path); | 223 console.error("Failed to load resource: " + path); |
224 return; | 224 return; |
225 } | 225 } |
226 var sourceURL = appendSourceURL ? Runtime.resolveSourceURL(path) : ""; | 226 var sourceURL = appendSourceURL ? Runtime.resolveSourceURL(path) : ""; |
227 Runtime.cachedResources[path] = content + sourceURL; | 227 Runtime.cachedResources[path] = content + sourceURL; |
228 } | 228 } |
229 } | 229 }; |
230 | 230 |
231 /** | 231 /** |
232 * @param {string} appName | 232 * @param {string} appName |
233 * @return {!Promise.<undefined>} | 233 * @return {!Promise.<undefined>} |
234 */ | 234 */ |
235 Runtime.startApplication = function(appName) | 235 Runtime.startApplication = function(appName) |
236 { | 236 { |
237 console.timeStamp("Runtime.startApplication"); | 237 console.timeStamp("Runtime.startApplication"); |
238 | 238 |
239 var allDescriptorsByName = {}; | 239 var allDescriptorsByName = {}; |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
283 moduleDescriptors[i].name = configuration[i]["name"]; | 283 moduleDescriptors[i].name = configuration[i]["name"]; |
284 moduleDescriptors[i].condition = configuration[i]["condition"]; | 284 moduleDescriptors[i].condition = configuration[i]["condition"]; |
285 moduleDescriptors[i].remote = configuration[i]["type"] === "remo
te"; | 285 moduleDescriptors[i].remote = configuration[i]["type"] === "remo
te"; |
286 } | 286 } |
287 self.runtime = new Runtime(moduleDescriptors); | 287 self.runtime = new Runtime(moduleDescriptors); |
288 if (coreModuleNames) | 288 if (coreModuleNames) |
289 return /** @type {!Promise<undefined>} */ (self.runtime._loadAut
oStartModules(coreModuleNames)); | 289 return /** @type {!Promise<undefined>} */ (self.runtime._loadAut
oStartModules(coreModuleNames)); |
290 return Promise.resolve(); | 290 return Promise.resolve(); |
291 } | 291 } |
292 } | 292 } |
293 } | 293 }; |
294 | 294 |
295 /** | 295 /** |
296 * @param {string} appName | 296 * @param {string} appName |
297 * @return {!Promise.<undefined>} | 297 * @return {!Promise.<undefined>} |
298 */ | 298 */ |
299 Runtime.startWorker = function(appName) | 299 Runtime.startWorker = function(appName) |
300 { | 300 { |
301 return Runtime.startApplication(appName).then(sendWorkerReady); | 301 return Runtime.startApplication(appName).then(sendWorkerReady); |
302 | 302 |
303 function sendWorkerReady() | 303 function sendWorkerReady() |
304 { | 304 { |
305 self.postMessage("workerReady"); | 305 self.postMessage("workerReady"); |
306 } | 306 } |
307 } | 307 }; |
308 | 308 |
309 /** @type {?function(!MessagePort)} */ | 309 /** @type {?function(!MessagePort)} */ |
310 Runtime._sharedWorkerNewPortCallback = null; | 310 Runtime._sharedWorkerNewPortCallback = null; |
311 /** @type {!Array<!MessagePort>} */ | 311 /** @type {!Array<!MessagePort>} */ |
312 Runtime._sharedWorkerConnectedPorts = []; | 312 Runtime._sharedWorkerConnectedPorts = []; |
313 | 313 |
314 /** | 314 /** |
315 * @param {string} appName | 315 * @param {string} appName |
316 */ | 316 */ |
317 Runtime.startSharedWorker = function(appName) | 317 Runtime.startSharedWorker = function(appName) |
318 { | 318 { |
319 var startPromise = Runtime.startApplication(appName); | 319 var startPromise = Runtime.startApplication(appName); |
320 | 320 |
321 /** | 321 /** |
322 * @param {!MessageEvent} event | 322 * @param {!MessageEvent} event |
323 */ | 323 */ |
324 self.onconnect = function(event) | 324 self.onconnect = function(event) |
325 { | 325 { |
326 var newPort = /** @type {!MessagePort} */ (event.ports[0]); | 326 var newPort = /** @type {!MessagePort} */ (event.ports[0]); |
327 startPromise.then(sendWorkerReadyAndContinue); | 327 startPromise.then(sendWorkerReadyAndContinue); |
328 | 328 |
329 function sendWorkerReadyAndContinue() | 329 function sendWorkerReadyAndContinue() |
330 { | 330 { |
331 newPort.postMessage("workerReady"); | 331 newPort.postMessage("workerReady"); |
332 if (Runtime._sharedWorkerNewPortCallback) | 332 if (Runtime._sharedWorkerNewPortCallback) |
333 Runtime._sharedWorkerNewPortCallback.call(null, newPort); | 333 Runtime._sharedWorkerNewPortCallback.call(null, newPort); |
334 else | 334 else |
335 Runtime._sharedWorkerConnectedPorts.push(newPort); | 335 Runtime._sharedWorkerConnectedPorts.push(newPort); |
336 } | 336 } |
337 } | 337 }; |
338 } | 338 }; |
339 | 339 |
340 /** | 340 /** |
341 * @param {function(!MessagePort)} callback | 341 * @param {function(!MessagePort)} callback |
342 */ | 342 */ |
343 Runtime.setSharedWorkerNewPortCallback = function(callback) | 343 Runtime.setSharedWorkerNewPortCallback = function(callback) |
344 { | 344 { |
345 Runtime._sharedWorkerNewPortCallback = callback; | 345 Runtime._sharedWorkerNewPortCallback = callback; |
346 while (Runtime._sharedWorkerConnectedPorts.length) { | 346 while (Runtime._sharedWorkerConnectedPorts.length) { |
347 var port = Runtime._sharedWorkerConnectedPorts.shift(); | 347 var port = Runtime._sharedWorkerConnectedPorts.shift(); |
348 callback.call(null, port); | 348 callback.call(null, port); |
349 } | 349 } |
350 } | 350 }; |
351 | 351 |
352 /** | 352 /** |
353 * @param {string} name | 353 * @param {string} name |
354 * @return {?string} | 354 * @return {?string} |
355 */ | 355 */ |
356 Runtime.queryParam = function(name) | 356 Runtime.queryParam = function(name) |
357 { | 357 { |
358 return Runtime._queryParamsObject[name] || null; | 358 return Runtime._queryParamsObject[name] || null; |
359 } | 359 }; |
360 | 360 |
361 /** | 361 /** |
362 * @return {!Object} | 362 * @return {!Object} |
363 */ | 363 */ |
364 Runtime._experimentsSetting = function() | 364 Runtime._experimentsSetting = function() |
365 { | 365 { |
366 try { | 366 try { |
367 return /** @type {!Object} */ (JSON.parse(self.localStorage && self.loca
lStorage["experiments"] ? self.localStorage["experiments"] : "{}")); | 367 return /** @type {!Object} */ (JSON.parse(self.localStorage && self.loca
lStorage["experiments"] ? self.localStorage["experiments"] : "{}")); |
368 } catch (e) { | 368 } catch (e) { |
369 console.error("Failed to parse localStorage['experiments']"); | 369 console.error("Failed to parse localStorage['experiments']"); |
370 return {}; | 370 return {}; |
371 } | 371 } |
372 } | 372 }; |
373 | 373 |
374 Runtime._console = console; | 374 Runtime._console = console; |
375 Runtime._originalAssert = console.assert; | 375 Runtime._originalAssert = console.assert; |
376 Runtime._assert = function(value, message) | 376 Runtime._assert = function(value, message) |
377 { | 377 { |
378 if (value) | 378 if (value) |
379 return; | 379 return; |
380 Runtime._originalAssert.call(Runtime._console, value, message + " " + new Er
ror().stack); | 380 Runtime._originalAssert.call(Runtime._console, value, message + " " + new Er
ror().stack); |
381 } | 381 }; |
382 | 382 |
383 Runtime._platform = ""; | 383 Runtime._platform = ""; |
384 | 384 |
385 /** | 385 /** |
386 * @param {string} platform | 386 * @param {string} platform |
387 */ | 387 */ |
388 Runtime.setPlatform = function(platform) | 388 Runtime.setPlatform = function(platform) |
389 { | 389 { |
390 Runtime._platform = platform; | 390 Runtime._platform = platform; |
391 } | 391 }; |
392 | 392 |
393 Runtime.prototype = { | 393 Runtime.prototype = { |
394 useTestBase: function() | 394 useTestBase: function() |
395 { | 395 { |
396 Runtime._remoteBase = "http://localhost:8000/inspector-sources/"; | 396 Runtime._remoteBase = "http://localhost:8000/inspector-sources/"; |
397 if (Runtime.queryParam("debugFrontend")) | 397 if (Runtime.queryParam("debugFrontend")) |
398 Runtime._remoteBase += "debug/"; | 398 Runtime._remoteBase += "debug/"; |
399 }, | 399 }, |
400 | 400 |
401 /** | 401 /** |
(...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
582 * @return {!Object} | 582 * @return {!Object} |
583 */ | 583 */ |
584 sharedInstance: function(constructorFunction) | 584 sharedInstance: function(constructorFunction) |
585 { | 585 { |
586 if (Runtime._instanceSymbol in constructorFunction) | 586 if (Runtime._instanceSymbol in constructorFunction) |
587 return constructorFunction[Runtime._instanceSymbol]; | 587 return constructorFunction[Runtime._instanceSymbol]; |
588 var instance = new constructorFunction(); | 588 var instance = new constructorFunction(); |
589 constructorFunction[Runtime._instanceSymbol] = instance; | 589 constructorFunction[Runtime._instanceSymbol] = instance; |
590 return instance; | 590 return instance; |
591 } | 591 } |
592 } | 592 }; |
593 | 593 |
594 /** | 594 /** |
595 * @constructor | 595 * @constructor |
596 */ | 596 */ |
597 Runtime.ModuleDescriptor = function() | 597 Runtime.ModuleDescriptor = function() |
598 { | 598 { |
599 /** | 599 /** |
600 * @type {string} | 600 * @type {string} |
601 */ | 601 */ |
602 this.name; | 602 this.name; |
(...skipping 15 matching lines...) Expand all Loading... |
618 | 618 |
619 /** | 619 /** |
620 * @type {string|undefined} | 620 * @type {string|undefined} |
621 */ | 621 */ |
622 this.condition; | 622 this.condition; |
623 | 623 |
624 /** | 624 /** |
625 * @type {boolean|undefined} | 625 * @type {boolean|undefined} |
626 */ | 626 */ |
627 this.remote; | 627 this.remote; |
628 } | 628 }; |
629 | 629 |
630 /** | 630 /** |
631 * @constructor | 631 * @constructor |
632 */ | 632 */ |
633 Runtime.ExtensionDescriptor = function() | 633 Runtime.ExtensionDescriptor = function() |
634 { | 634 { |
635 /** | 635 /** |
636 * @type {string} | 636 * @type {string} |
637 */ | 637 */ |
638 this.type; | 638 this.type; |
639 | 639 |
640 /** | 640 /** |
641 * @type {string|undefined} | 641 * @type {string|undefined} |
642 */ | 642 */ |
643 this.className; | 643 this.className; |
644 | 644 |
645 /** | 645 /** |
646 * @type {string|undefined} | 646 * @type {string|undefined} |
647 */ | 647 */ |
648 this.factoryName; | 648 this.factoryName; |
649 | 649 |
650 /** | 650 /** |
651 * @type {!Array.<string>|undefined} | 651 * @type {!Array.<string>|undefined} |
652 */ | 652 */ |
653 this.contextTypes; | 653 this.contextTypes; |
654 } | 654 }; |
655 | 655 |
656 /** | 656 /** |
657 * @constructor | 657 * @constructor |
658 * @param {!Runtime} manager | 658 * @param {!Runtime} manager |
659 * @param {!Runtime.ModuleDescriptor} descriptor | 659 * @param {!Runtime.ModuleDescriptor} descriptor |
660 */ | 660 */ |
661 Runtime.Module = function(manager, descriptor) | 661 Runtime.Module = function(manager, descriptor) |
662 { | 662 { |
663 this._manager = manager; | 663 this._manager = manager; |
664 this._descriptor = descriptor; | 664 this._descriptor = descriptor; |
665 this._name = descriptor.name; | 665 this._name = descriptor.name; |
666 /** @type {!Array<!Runtime.Extension>} */ | 666 /** @type {!Array<!Runtime.Extension>} */ |
667 this._extensions = []; | 667 this._extensions = []; |
668 | 668 |
669 /** @type {!Map<string, !Array<!Runtime.Extension>>} */ | 669 /** @type {!Map<string, !Array<!Runtime.Extension>>} */ |
670 this._extensionsByClassName = new Map(); | 670 this._extensionsByClassName = new Map(); |
671 var extensions = /** @type {?Array.<!Runtime.ExtensionDescriptor>} */ (descr
iptor.extensions); | 671 var extensions = /** @type {?Array.<!Runtime.ExtensionDescriptor>} */ (descr
iptor.extensions); |
672 for (var i = 0; extensions && i < extensions.length; ++i) { | 672 for (var i = 0; extensions && i < extensions.length; ++i) { |
673 var extension = new Runtime.Extension(this, extensions[i]); | 673 var extension = new Runtime.Extension(this, extensions[i]); |
674 this._manager._extensions.push(extension); | 674 this._manager._extensions.push(extension); |
675 this._extensions.push(extension); | 675 this._extensions.push(extension); |
676 } | 676 } |
677 this._loadedForTest = false; | 677 this._loadedForTest = false; |
678 } | 678 }; |
679 | 679 |
680 Runtime.Module.prototype = { | 680 Runtime.Module.prototype = { |
681 /** | 681 /** |
682 * @return {string} | 682 * @return {string} |
683 */ | 683 */ |
684 name: function() | 684 name: function() |
685 { | 685 { |
686 return this._name; | 686 return this._name; |
687 }, | 687 }, |
688 | 688 |
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
781 substituteURL: function(value) | 781 substituteURL: function(value) |
782 { | 782 { |
783 var base = this._remoteBase() || ""; | 783 var base = this._remoteBase() || ""; |
784 return value.replace(/@url\(([^\)]*?)\)/g, convertURL.bind(this)); | 784 return value.replace(/@url\(([^\)]*?)\)/g, convertURL.bind(this)); |
785 | 785 |
786 function convertURL(match, url) | 786 function convertURL(match, url) |
787 { | 787 { |
788 return base + this._modularizeURL(url); | 788 return base + this._modularizeURL(url); |
789 } | 789 } |
790 } | 790 } |
791 } | 791 }; |
792 | 792 |
793 /** | 793 /** |
794 * @param {!Object} descriptor | 794 * @param {!Object} descriptor |
795 * @return {boolean} | 795 * @return {boolean} |
796 */ | 796 */ |
797 Runtime._isDescriptorEnabled = function(descriptor) | 797 Runtime._isDescriptorEnabled = function(descriptor) |
798 { | 798 { |
799 var activatorExperiment = descriptor["experiment"]; | 799 var activatorExperiment = descriptor["experiment"]; |
800 if (activatorExperiment === "*") | 800 if (activatorExperiment === "*") |
801 return Runtime.experiments.supportEnabled(); | 801 return Runtime.experiments.supportEnabled(); |
802 if (activatorExperiment && activatorExperiment.startsWith("!") && Runtime.ex
periments.isEnabled(activatorExperiment.substring(1))) | 802 if (activatorExperiment && activatorExperiment.startsWith("!") && Runtime.ex
periments.isEnabled(activatorExperiment.substring(1))) |
803 return false; | 803 return false; |
804 if (activatorExperiment && !activatorExperiment.startsWith("!") && !Runtime.
experiments.isEnabled(activatorExperiment)) | 804 if (activatorExperiment && !activatorExperiment.startsWith("!") && !Runtime.
experiments.isEnabled(activatorExperiment)) |
805 return false; | 805 return false; |
806 var condition = descriptor["condition"]; | 806 var condition = descriptor["condition"]; |
807 if (condition && !condition.startsWith("!") && !Runtime.queryParam(condition
)) | 807 if (condition && !condition.startsWith("!") && !Runtime.queryParam(condition
)) |
808 return false; | 808 return false; |
809 if (condition && condition.startsWith("!") && Runtime.queryParam(condition.s
ubstring(1))) | 809 if (condition && condition.startsWith("!") && Runtime.queryParam(condition.s
ubstring(1))) |
810 return false; | 810 return false; |
811 return true; | 811 return true; |
812 } | 812 }; |
813 | 813 |
814 /** | 814 /** |
815 * @constructor | 815 * @constructor |
816 * @param {!Runtime.Module} module | 816 * @param {!Runtime.Module} module |
817 * @param {!Runtime.ExtensionDescriptor} descriptor | 817 * @param {!Runtime.ExtensionDescriptor} descriptor |
818 */ | 818 */ |
819 Runtime.Extension = function(module, descriptor) | 819 Runtime.Extension = function(module, descriptor) |
820 { | 820 { |
821 this._module = module; | 821 this._module = module; |
822 this._descriptor = descriptor; | 822 this._descriptor = descriptor; |
823 | 823 |
824 this._type = descriptor.type; | 824 this._type = descriptor.type; |
825 this._hasTypeClass = this._type.charAt(0) === "@"; | 825 this._hasTypeClass = this._type.charAt(0) === "@"; |
826 | 826 |
827 /** | 827 /** |
828 * @type {?string} | 828 * @type {?string} |
829 */ | 829 */ |
830 this._className = descriptor.className || null; | 830 this._className = descriptor.className || null; |
831 this._factoryName = descriptor.factoryName || null; | 831 this._factoryName = descriptor.factoryName || null; |
832 } | 832 }; |
833 | 833 |
834 Runtime.Extension.prototype = { | 834 Runtime.Extension.prototype = { |
835 /** | 835 /** |
836 * @return {!Object} | 836 * @return {!Object} |
837 */ | 837 */ |
838 descriptor: function() | 838 descriptor: function() |
839 { | 839 { |
840 return this._descriptor; | 840 return this._descriptor; |
841 }, | 841 }, |
842 | 842 |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
916 { | 916 { |
917 var contextTypes = this.descriptor().contextTypes; | 917 var contextTypes = this.descriptor().contextTypes; |
918 if (!contextTypes) | 918 if (!contextTypes) |
919 return false; | 919 return false; |
920 for (var i = 0; i < contextTypes.length; ++i) { | 920 for (var i = 0; i < contextTypes.length; ++i) { |
921 if (contextType === this._module._manager._resolve(contextTypes[i])) | 921 if (contextType === this._module._manager._resolve(contextTypes[i])) |
922 return true; | 922 return true; |
923 } | 923 } |
924 return false; | 924 return false; |
925 } | 925 } |
926 } | 926 }; |
927 | 927 |
928 /** | 928 /** |
929 * @constructor | 929 * @constructor |
930 */ | 930 */ |
931 Runtime.ExperimentsSupport = function() | 931 Runtime.ExperimentsSupport = function() |
932 { | 932 { |
933 this._supportEnabled = Runtime.queryParam("experiments") !== null; | 933 this._supportEnabled = Runtime.queryParam("experiments") !== null; |
934 this._experiments = []; | 934 this._experiments = []; |
935 this._experimentNames = {}; | 935 this._experimentNames = {}; |
936 this._enabledTransiently = {}; | 936 this._enabledTransiently = {}; |
937 } | 937 }; |
938 | 938 |
939 Runtime.ExperimentsSupport.prototype = { | 939 Runtime.ExperimentsSupport.prototype = { |
940 /** | 940 /** |
941 * @return {!Array.<!Runtime.Experiment>} | 941 * @return {!Array.<!Runtime.Experiment>} |
942 */ | 942 */ |
943 allConfigurableExperiments: function() | 943 allConfigurableExperiments: function() |
944 { | 944 { |
945 var result = []; | 945 var result = []; |
946 for (var i = 0; i < this._experiments.length; i++) { | 946 for (var i = 0; i < this._experiments.length; i++) { |
947 var experiment = this._experiments[i]; | 947 var experiment = this._experiments[i]; |
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1048 this._setExperimentsSetting(cleanedUpExperimentSetting); | 1048 this._setExperimentsSetting(cleanedUpExperimentSetting); |
1049 }, | 1049 }, |
1050 | 1050 |
1051 /** | 1051 /** |
1052 * @param {string} experimentName | 1052 * @param {string} experimentName |
1053 */ | 1053 */ |
1054 _checkExperiment: function(experimentName) | 1054 _checkExperiment: function(experimentName) |
1055 { | 1055 { |
1056 Runtime._assert(this._experimentNames[experimentName], "Unknown experime
nt " + experimentName); | 1056 Runtime._assert(this._experimentNames[experimentName], "Unknown experime
nt " + experimentName); |
1057 } | 1057 } |
1058 } | 1058 }; |
1059 | 1059 |
1060 /** | 1060 /** |
1061 * @constructor | 1061 * @constructor |
1062 * @param {!Runtime.ExperimentsSupport} experiments | 1062 * @param {!Runtime.ExperimentsSupport} experiments |
1063 * @param {string} name | 1063 * @param {string} name |
1064 * @param {string} title | 1064 * @param {string} title |
1065 * @param {boolean} hidden | 1065 * @param {boolean} hidden |
1066 */ | 1066 */ |
1067 Runtime.Experiment = function(experiments, name, title, hidden) | 1067 Runtime.Experiment = function(experiments, name, title, hidden) |
1068 { | 1068 { |
1069 this.name = name; | 1069 this.name = name; |
1070 this.title = title; | 1070 this.title = title; |
1071 this.hidden = hidden; | 1071 this.hidden = hidden; |
1072 this._experiments = experiments; | 1072 this._experiments = experiments; |
1073 } | 1073 }; |
1074 | 1074 |
1075 Runtime.Experiment.prototype = { | 1075 Runtime.Experiment.prototype = { |
1076 /** | 1076 /** |
1077 * @return {boolean} | 1077 * @return {boolean} |
1078 */ | 1078 */ |
1079 isEnabled: function() | 1079 isEnabled: function() |
1080 { | 1080 { |
1081 return this._experiments.isEnabled(this.name); | 1081 return this._experiments.isEnabled(this.name); |
1082 }, | 1082 }, |
1083 | 1083 |
1084 /** | 1084 /** |
1085 * @param {boolean} enabled | 1085 * @param {boolean} enabled |
1086 */ | 1086 */ |
1087 setEnabled: function(enabled) | 1087 setEnabled: function(enabled) |
1088 { | 1088 { |
1089 this._experiments.setEnabled(this.name, enabled); | 1089 this._experiments.setEnabled(this.name, enabled); |
1090 } | 1090 } |
1091 } | 1091 }; |
1092 | 1092 |
1093 {(function parseQueryParameters() | 1093 {(function parseQueryParameters() |
1094 { | 1094 { |
1095 var queryParams = location.search; | 1095 var queryParams = location.search; |
1096 if (!queryParams) | 1096 if (!queryParams) |
1097 return; | 1097 return; |
1098 var params = queryParams.substring(1).split("&"); | 1098 var params = queryParams.substring(1).split("&"); |
1099 for (var i = 0; i < params.length; ++i) { | 1099 for (var i = 0; i < params.length; ++i) { |
1100 var pair = params[i].split("="); | 1100 var pair = params[i].split("="); |
1101 var name = pair.shift(); | 1101 var name = pair.shift(); |
(...skipping 20 matching lines...) Expand all Loading... |
1122 * @param {string} path | 1122 * @param {string} path |
1123 * @return {string} | 1123 * @return {string} |
1124 */ | 1124 */ |
1125 Runtime.resolveSourceURL = function(path) | 1125 Runtime.resolveSourceURL = function(path) |
1126 { | 1126 { |
1127 var sourceURL = self.location.href; | 1127 var sourceURL = self.location.href; |
1128 if (self.location.search) | 1128 if (self.location.search) |
1129 sourceURL = sourceURL.replace(self.location.search, ""); | 1129 sourceURL = sourceURL.replace(self.location.search, ""); |
1130 sourceURL = sourceURL.substring(0, sourceURL.lastIndexOf("/") + 1) + path; | 1130 sourceURL = sourceURL.substring(0, sourceURL.lastIndexOf("/") + 1) + path; |
1131 return "\n/*# sourceURL=" + sourceURL + " */"; | 1131 return "\n/*# sourceURL=" + sourceURL + " */"; |
1132 } | 1132 }; |
1133 | 1133 |
1134 /** | 1134 /** |
1135 * @interface | 1135 * @interface |
1136 */ | 1136 */ |
1137 function ServicePort() { } | 1137 function ServicePort() { } |
1138 | 1138 |
1139 ServicePort.prototype = { | 1139 ServicePort.prototype = { |
1140 /** | 1140 /** |
1141 * @param {function(string)} messageHandler | 1141 * @param {function(string)} messageHandler |
1142 * @param {function(string)} closeHandler | 1142 * @param {function(string)} closeHandler |
1143 */ | 1143 */ |
1144 setHandlers: function(messageHandler, closeHandler) { }, | 1144 setHandlers: function(messageHandler, closeHandler) { }, |
1145 | 1145 |
1146 /** | 1146 /** |
1147 * @param {string} message | 1147 * @param {string} message |
1148 * @return {!Promise<boolean>} | 1148 * @return {!Promise<boolean>} |
1149 */ | 1149 */ |
1150 send: function(message) { }, | 1150 send: function(message) { }, |
1151 | 1151 |
1152 /** | 1152 /** |
1153 * @return {!Promise<boolean>} | 1153 * @return {!Promise<boolean>} |
1154 */ | 1154 */ |
1155 close: function() { } | 1155 close: function() { } |
1156 } | 1156 }; |
1157 | 1157 |
1158 /** @type {!Runtime} */ | 1158 /** @type {!Runtime} */ |
1159 var runtime; | 1159 var runtime; |
OLD | NEW |