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

Unified Diff: dart/sdk/lib/_internal/lib/isolate_helper.dart

Issue 23523003: Address a number of issues related to computation of currentScript and deferred loading. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge
Patch Set: Add tests Created 7 years, 4 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « dart/sdk/lib/_internal/lib/async_patch.dart ('k') | dart/tests/compiler/dart2js_extra/dart2js_extra.status » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: dart/sdk/lib/_internal/lib/isolate_helper.dart
diff --git a/dart/sdk/lib/_internal/lib/isolate_helper.dart b/dart/sdk/lib/_internal/lib/isolate_helper.dart
index d59dbb81660e6c4fe0d683f4648e3a6025944015..9fe12b06ee11bf0359f27f2e564a327ae00de68f 100644
--- a/dart/sdk/lib/_internal/lib/isolate_helper.dart
+++ b/dart/sdk/lib/_internal/lib/isolate_helper.dart
@@ -424,29 +424,49 @@ class IsolateNatives {
/// Associates an ID with a native worker object.
static final Expando<int> workerIds = new Expando<int>();
+ static bool get isD8 {
+ return JS('bool',
+ 'typeof version == "function"'
+ ' && typeof os == "object" && "system" in os');
+ }
+
+ static bool get isJsshell {
+ return JS('bool',
+ 'typeof version == "function" && typeof system == "function"');
+ }
+
/**
* The src url for the script tag that loaded this code. Used to create
* JavaScript workers.
*/
static String computeThisScript() {
- var currentScript = JS('', r'#.$currentScript', JS_CURRENT_ISOLATE());
+ var currentScript = JS('', r'init.currentScript');
if (currentScript != null) {
return JS('String', 'String(#.src)', currentScript);
}
+ if (isD8) return computeThisScriptD8();
+ if (isJsshell) return computeThisScriptJsshell();
+ return null;
+ }
+
+ static String computeThisScriptJsshell() {
+ return JS('String|Null', 'thisFilename()');
+ }
- // TODO(ahe): The following is for supporting command-line engines
- // such as d8 and jsshell. We should move this code to a helper
- // library that is only loaded when testing on those engines.
+ static String computeThisScriptD8() {
+ // TODO(ahe): The following is for supporting D8. We should move this code
+ // to a helper library that is only loaded when testing on D8.
var stack = JS('String|Null', 'new Error().stack');
if (stack == null) {
// According to Internet Explorer documentation, the stack
// property is not set until the exception is thrown. The stack
// property was not provided until IE10.
- stack = JS('String',
+ stack = JS('String|Null',
'(function() {'
'try { throw new Error() } catch(e) { return e.stack }'
'})()');
+ if (stack == null) throw new UnsupportedError('No stack trace');
}
var pattern, matches;
« no previous file with comments | « dart/sdk/lib/_internal/lib/async_patch.dart ('k') | dart/tests/compiler/dart2js_extra/dart2js_extra.status » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698