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

Side by Side Diff: lib/runtime/dart_library.js

Issue 1521283003: Run browser tests on Atom/Electron (Closed) Base URL: https://github.com/dart-lang/dev_compiler.git@master
Patch Set: Created 5 years 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
« karma.conf.js ('K') | « karma.conf.js ('k') | package.json » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 /* This file defines the module loader for the dart runtime. 5 /* This file defines the module loader for the dart runtime.
6 */ 6 */
7 7
8 var dart_library = 8 var dart_library =
9 typeof module != "undefined" && module.exports || {}; 9 typeof module != "undefined" && module.exports || {};
10 10
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
44 }); 44 });
45 } 45 }
46 46
47 loadLazyImports(pendingSet) { 47 loadLazyImports(pendingSet) {
48 return this.handleImports(pendingSet, (lib) => lib.load()); 48 return this.handleImports(pendingSet, (lib) => lib.load());
49 } 49 }
50 50
51 handleImports(list, handler) { 51 handleImports(list, handler) {
52 let results = []; 52 let results = [];
53 for (let name of list) { 53 for (let name of list) {
54 let lib = libraries[name]; 54 let lib = libraries.get(name);
ochafik 2015/12/14 02:46:16 Electron doesn't like [] on Map yet?
55 if (!lib) { 55 if (!lib) {
56 throwLibraryError('Library not available: ' + name); 56 throwLibraryError('Library not available: ' + name);
57 } 57 }
58 results.push(handler(lib)); 58 results.push(handler(lib));
59 } 59 }
60 return results; 60 return results;
61 } 61 }
62 62
63 load(inheritedPendingSet) { 63 load(inheritedPendingSet) {
64 // Check for cycles 64 // Check for cycles
(...skipping 28 matching lines...) Expand all
93 return this._library; 93 return this._library;
94 } 94 }
95 } 95 }
96 LibraryLoader.NOT_LOADED = 0; 96 LibraryLoader.NOT_LOADED = 0;
97 LibraryLoader.LOADING = 1; 97 LibraryLoader.LOADING = 1;
98 LibraryLoader.LOADED = 2; 98 LibraryLoader.LOADED = 2;
99 LibraryLoader.READY = 3; 99 LibraryLoader.READY = 3;
100 100
101 // Map from name to LibraryLoader 101 // Map from name to LibraryLoader
102 let libraries = new Map(); 102 let libraries = new Map();
103 dart_library.libraries = function() { return libraries.keys(); }
103 104
104 function library(name, defaultValue, imports, lazyImports, loader) { 105 function library(name, defaultValue, imports, lazyImports, loader) {
105 return libraries[name] = 106 let result = new LibraryLoader(name, defaultValue, imports, lazyImports, loa der);
106 new LibraryLoader(name, defaultValue, imports, lazyImports, loader); 107 libraries.set(name, result);
108 return result;
107 } 109 }
108 dart_library.library = library; 110 dart_library.library = library;
109 111
110 function import_(libraryName) { 112 function import_(libraryName) {
111 bootstrap(); 113 bootstrap();
112 let loader = libraries[libraryName]; 114 let loader = libraries.get(libraryName);
113 // TODO(vsm): A user might call this directly from JS (as we do in tests). 115 // TODO(vsm): A user might call this directly from JS (as we do in tests).
114 // We may want a different error type. 116 // We may want a different error type.
115 if (!loader) throwLibraryError('Library not found: ' + libraryName); 117 if (!loader) throwLibraryError('Library not found: ' + libraryName);
116 return loader.load(); 118 return loader.load();
117 } 119 }
118 dart_library.import = import_; 120 dart_library.import = import_;
119 121
120 function start(libraryName) { 122 function start(libraryName) {
121 let library = import_(libraryName); 123 let library = import_(libraryName);
122 let _isolate_helper = import_('dart/_isolate_helper'); 124 let _isolate_helper = import_('dart/_isolate_helper');
(...skipping 18 matching lines...) Expand all
141 // See: https://github.com/dart-lang/dev_compiler/issues/173 143 // See: https://github.com/dart-lang/dev_compiler/issues/173
142 if (typeof NodeList !== "undefined") { 144 if (typeof NodeList !== "undefined") {
143 NodeList.prototype.get = function(i) { return this[i]; }; 145 NodeList.prototype.get = function(i) { return this[i]; };
144 NamedNodeMap.prototype.get = function(i) { return this[i]; }; 146 NamedNodeMap.prototype.get = function(i) { return this[i]; };
145 DOMTokenList.prototype.get = function(i) { return this[i]; }; 147 DOMTokenList.prototype.get = function(i) { return this[i]; };
146 HTMLCollection.prototype.get = function(i) { return this[i]; }; 148 HTMLCollection.prototype.get = function(i) { return this[i]; };
147 } 149 }
148 } 150 }
149 151
150 })(dart_library); 152 })(dart_library);
OLDNEW
« karma.conf.js ('K') | « karma.conf.js ('k') | package.json » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698