Skip to content

Commit

Permalink
Better feature-testing for Chrome browser
Browse files Browse the repository at this point in the history
R=alanknight@google.com

Review URL: https://codereview.chromium.org//73203002

git-svn-id: http://dart.googlecode.com/svn/branches/bleeding_edge/dart@30649 260f80e4-7a28-3924-810f-c04153c831b5
  • Loading branch information
sra@google.com committed Nov 25, 2013
1 parent a2b400d commit dfadb98
Showing 1 changed file with 8 additions and 9 deletions.
17 changes: 8 additions & 9 deletions sdk/lib/_internal/lib/native_helper.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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;
Expand Down

0 comments on commit dfadb98

Please sign in to comment.