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

Unified Diff: lib/isolate/frog/natives.js

Issue 10050035: isolate: fix how we get the current script now that frog automatically wraps the (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 8 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 | « lib/isolate/frog/isolateimpl.dart ('k') | tests/isolate/src/APIv2_computeThisScriptBrowserTest.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: lib/isolate/frog/natives.js
diff --git a/lib/isolate/frog/natives.js b/lib/isolate/frog/natives.js
index 62ad76e63f7af6254b94c82dccd00f5514fb9fba..2808ecb2cc9aeaa989dd5e06d30d8e2bdb3e8e1c 100644
--- a/lib/isolate/frog/natives.js
+++ b/lib/isolate/frog/natives.js
@@ -7,6 +7,10 @@
var $globalThis = this;
var $globals = null;
var $globalState = null;
+var $thisScriptUrl = null;
+var $isWorker = typeof ($globalThis['importScripts']) != 'undefined';
+var $supportsWorkers =
+ $isWorker || ((typeof $globalThis['Worker']) != 'undefined');
function $initGlobals(context) { context.isolateStatics = {}; }
function $setGlobals(context) { $globals = context.isolateStatics; }
@@ -39,3 +43,21 @@ Function.prototype.wrap$call$1 = function() {
this.wrap$call$1 = function() { return this.wrap$1; };
return this.wrap$1;
};
+
+$thisScriptUrl = (function () {
+ if (!$supportsWorkers || $isWorker) return (void 0);
+
+ // TODO(5334778): Find a cross-platform non-brittle way of getting the
+ // currently running script.
+ var scripts = document.getElementsByTagName('script');
+ // The scripts variable only contains the scripts that have already been
+ // executed. The last one is the currently running script.
+ var script = scripts[scripts.length - 1];
+ var src = script && script.src;
+ if (!src) {
+ // TODO()
+ src = "FIXME:5407062" + "_" + Math.random().toString();
+ if (script) script.src = src;
+ }
+ return src;
+})();
« no previous file with comments | « lib/isolate/frog/isolateimpl.dart ('k') | tests/isolate/src/APIv2_computeThisScriptBrowserTest.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698