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

Unified Diff: dart/sdk/lib/js/dart2js/js_dart2js.dart

Issue 650093002: Avoid throwing exceptions on inter-frame communication (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge
Patch Set: Merged with r41115 and addedTODO with reference to bug. Created 6 years, 2 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 | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: dart/sdk/lib/js/dart2js/js_dart2js.dart
diff --git a/dart/sdk/lib/js/dart2js/js_dart2js.dart b/dart/sdk/lib/js/dart2js/js_dart2js.dart
index 9bf0a20f04354b046b3ddb49833412b3734116e6..6de50320ae1f5770d1a63cd21d13b48a083f50aa 100644
--- a/dart/sdk/lib/js/dart2js/js_dart2js.dart
+++ b/dart/sdk/lib/js/dart2js/js_dart2js.dart
@@ -471,11 +471,14 @@ const _JS_OBJECT_PROPERTY_NAME = r'_$dart_jsObject';
const _JS_FUNCTION_PROPERTY_NAME = r'$dart_jsFunction';
bool _defineProperty(o, String name, value) {
- if (JS('bool', 'Object.isExtensible(#)', o)) {
+ if (_isExtensible(o) &&
+ // TODO(ahe): Calling _hasOwnProperty to work around
+ // https://code.google.com/p/dart/issues/detail?id=21331.
+ !_hasOwnProperty(o, name)) {
try {
JS('void', 'Object.defineProperty(#, #, { value: #})', o, name, value);
return true;
- } catch(e) {
+ } catch (e) {
// object is native and lies about being extensible
// see https://bugzilla.mozilla.org/show_bug.cgi?id=775185
}
@@ -483,8 +486,14 @@ bool _defineProperty(o, String name, value) {
return false;
}
+bool _hasOwnProperty(o, String name) {
+ return JS('bool', 'Object.prototype.hasOwnProperty.call(#, #)', o, name);
+}
+
+bool _isExtensible(o) => JS('bool', 'Object.isExtensible(#)', o);
+
Object _getOwnProperty(o, String name) {
- if (JS('bool', 'Object.prototype.hasOwnProperty.call(#, #)', o, name)) {
+ if (_hasOwnProperty(o, name)) {
return JS('', '#[#]', o, name);
}
return null;
« 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