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

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

Issue 12288047: Change IsolateNatives.computeThisScript to use captured value of document.currentScript. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge
Patch Set: Use typeof object and don't use JS_CURRENT_ISOLATE before _globalState has been initialized. Created 7 years, 10 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
Index: dart/sdk/lib/_internal/compiler/implementation/lib/isolate_helper.dart
diff --git a/dart/sdk/lib/_internal/compiler/implementation/lib/isolate_helper.dart b/dart/sdk/lib/_internal/compiler/implementation/lib/isolate_helper.dart
index d25c058fbc80ad2449528eb3a4cd616d56953a0c..539e7b49baf8783aaa7eac5de878dc9cbc88d56b 100644
--- a/dart/sdk/lib/_internal/compiler/implementation/lib/isolate_helper.dart
+++ b/dart/sdk/lib/_internal/compiler/implementation/lib/isolate_helper.dart
@@ -12,7 +12,9 @@ import 'dart:_js_helper' show convertDartClosureToJS,
import 'dart:_foreign_helper' show DART_CLOSURE_TO_JS,
JS,
JS_CREATE_ISOLATE,
- JS_SET_CURRENT_ISOLATE;
+ JS_CURRENT_ISOLATE,
+ JS_SET_CURRENT_ISOLATE,
+ IsolateContext;
ReceivePort lazyPort;
@@ -202,7 +204,7 @@ class _Manager {
}
/** Context information tracked for each isolate. */
-class _IsolateContext {
+class _IsolateContext implements IsolateContext {
/** Current isolate id. */
int id;
@@ -406,19 +408,20 @@ class IsolateNatives {
* JavaScript workers.
*/
static String computeThisScript() {
- // TODO(ahe): The following works in Firefox during loading of the
- // script, and is being considered for the standard.
- // if (JS('String', 'typeof document') == 'object') {
- // var currentScript = JS('', 'document.currentScript');
- // if (JS('String', 'typeof #', currentScript) == 'object') {
- // return JS('String', '#.src', currentScript);
- // }
- // }
+ var currentScript = JS('', r'$.$currentScript');
+ if (currentScript != null) {
+ return JS('String', 'String(#.src)', currentScript);
+ }
+
+ // 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.
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.
+ // property is not set until the exception is thrown. The stack
+ // property was not provided until IE10.
stack = JS('String',
'(function() {'
'try { throw new Error() } catch(e) { return e.stack }'

Powered by Google App Engine
This is Rietveld 408576698