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

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

Issue 2379173002: Add native_testing library to mock @Native classes (Closed)
Patch Set: xxx Created 4 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
Index: sdk/lib/_internal/js_runtime/lib/native_helper.dart
diff --git a/sdk/lib/_internal/js_runtime/lib/native_helper.dart b/sdk/lib/_internal/js_runtime/lib/native_helper.dart
index 30d3ba7458745ee64f0a0888b47e10f3c32f51ff..c6aad9430c4302c697a8244b7b667d39de0029fd 100644
--- a/sdk/lib/_internal/js_runtime/lib/native_helper.dart
+++ b/sdk/lib/_internal/js_runtime/lib/native_helper.dart
@@ -449,13 +449,9 @@ applyHooksTransformer(transformer, hooks) {
const _baseHooks = const JS_CONST(r'''
function() {
- function typeNameInChrome(o) {
- var constructor = o.constructor;
- if (constructor) {
- var name = constructor.name;
- if (name) return name;
- }
- var s = Object.prototype.toString.call(o);
+ var toStringFunction = Object.prototype.toString;
+ function getTag(o) {
+ var s = toStringFunction.call(o);
return s.substring(8, s.length - 1);
}
function getUnknownTag(object, tag) {
@@ -463,7 +459,7 @@ function() {
// here allows [getUnknownTag] to be tested on d8.
if (/^HTML[A-Z].*Element$/.test(tag)) {
// Check that it is not a simple JavaScript object.
- var name = Object.prototype.toString.call(object);
+ var name = toStringFunction.call(object);
if (name == "[object Object]") return null;
return "HTMLElement";
}
@@ -484,7 +480,7 @@ function() {
var isBrowser = typeof navigator == "object";
return {
- getTag: typeNameInChrome,
+ getTag: getTag,
getUnknownTag: isBrowser ? getUnknownTagGenericBrowser : getUnknownTag,
prototypeForTag: prototypeForTag,
discriminator: discriminator };
« no previous file with comments | « sdk/lib/_internal/js_runtime/lib/interceptors.dart ('k') | tests/compiler/dart2js_native/abstract_class_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698