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

Unified Diff: pkg/compiler/lib/src/js_emitter/full_emitter/emitter.dart

Issue 2180533002: Feature-detect browser for assignment to __proto__. (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: fix regexp Created 4 years, 5 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 | « no previous file | pkg/compiler/lib/src/js_emitter/startup_emitter/fragment_emitter.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/compiler/lib/src/js_emitter/full_emitter/emitter.dart
diff --git a/pkg/compiler/lib/src/js_emitter/full_emitter/emitter.dart b/pkg/compiler/lib/src/js_emitter/full_emitter/emitter.dart
index 5bd1cb1d685faabde990fcdece9ab37e4ed9528a..6301e77d964edfdc6892b7164203d504f29968fb 100644
--- a/pkg/compiler/lib/src/js_emitter/full_emitter/emitter.dart
+++ b/pkg/compiler/lib/src/js_emitter/full_emitter/emitter.dart
@@ -1067,9 +1067,28 @@ class Emitter implements js_emitter.Emitter {
var cls = function () {};
cls.prototype = {'p': {}};
var object = new cls();
- return object.__proto__ &&
- object.__proto__.p === cls.prototype.p;
- })();
+ if (!(object.__proto__ && object.__proto__.p === cls.prototype.p))
+ return false;
+
+ try {
+ // Are we running on a platform where the performance is good?
+ // (i.e. Chrome or d8).
+
+ // Chrome userAgent?
+ if (typeof navigator != "undefined" &&
+ typeof navigator.userAgent == "string" &&
+ navigator.userAgent.indexOf("Chrome/") >= 0) return true;
+
+ // d8 version() looks like "N.N.N.N", jsshell version() like "N".
+ if (typeof version == "function" &&
+ version.length == 0) {
+ var v = version();
+ if (/^\d+\.\d+\.\d+\.\d+$/.test(v)) return true;
+ }
+ } catch(_) {}
+
+ return false;
+ })();
''');
}
« no previous file with comments | « no previous file | pkg/compiler/lib/src/js_emitter/startup_emitter/fragment_emitter.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698