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

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

Issue 73203002: Better feature-testing for Chrome browser (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 1 month 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 | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sdk/lib/_internal/lib/native_helper.dart
diff --git a/sdk/lib/_internal/lib/native_helper.dart b/sdk/lib/_internal/lib/native_helper.dart
index 799960e7e8ee7e0ed37eb5fdeab464f9e3deb47c..65008e41cf86e95e1541514d26e826a86219a9e9 100644
--- a/sdk/lib/_internal/lib/native_helper.dart
+++ b/sdk/lib/_internal/lib/native_helper.dart
@@ -484,13 +484,8 @@ function() {
*/
const _constructorNameFallback = const JS_CONST(r'''
function getTagFallback(o) {
- if (o == null) return "Null";
var constructor = o.constructor;
if (typeof constructor == "function") {
- var name = constructor.builtin$cls;
- if (typeof name == "string") return name;
- // The constructor is not null or undefined at this point. Try
- // to grab hold of its name.
name = constructor.name;
// If the name is a non-empty string, we use that as the type name of this
// object. On Firefox, we often get "Object" as the constructor name even
@@ -515,11 +510,15 @@ function(getTagFallback) {
// TODO(sra): Recognize jsshell.
if (typeof navigator != "object") return hooks;
- var userAgent = navigator.userAgent;
+ var ua = navigator.userAgent;
// TODO(antonm): remove a reference to DumpRenderTree.
- if (userAgent.indexOf("Chrome") >= 0 ||
- userAgent.indexOf("DumpRenderTree") >= 0) {
- return hooks;
+ if (ua.indexOf("DumpRenderTree") >= 0) return hooks;
+ if (ua.indexOf("Chrome") >= 0) {
+ // Confirm constructor name is usable for dispatch.
+ function confirm(p) {
+ return typeof window == "object" && window[p] && window[p].name == p;
+ }
+ if (confirm("Window") && confirm("HTMLElement")) return hooks;
}
hooks.getTag = getTagFallback;
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698