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

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: 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..961b5617b413bc89ba91b0bac5b2a171de4aad3e 100644
--- a/dart/sdk/lib/js/dart2js/js_dart2js.dart
+++ b/dart/sdk/lib/js/dart2js/js_dart2js.dart
@@ -471,11 +471,11 @@ 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) && !_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 +483,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