This repository has been archived by the owner on Apr 3, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 653
Make all the readonly attributes in Device Capabilities valid. #2355
Open
kygx-legend
wants to merge
1
commit into
crosswalk-project:master
Choose a base branch
from
kygx-legend:readonly
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+32
−2
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,6 +9,35 @@ var v8tools; | |
|
||
var unique_id = 0; | ||
|
||
function addConstProperty(obj, propertyKey, propertyValue) { | ||
Object.defineProperty(obj, propertyKey, { | ||
configurable: false, | ||
writable: false, | ||
value: propertyValue | ||
}); | ||
} | ||
|
||
function createConstClone(obj) { | ||
var const_obj = {}; | ||
for (var key in obj) { | ||
if (Array.isArray(obj[key])) { | ||
var obj_array = obj[key]; | ||
var const_obj_array = []; | ||
for (var i = 0; i < obj_array.length; ++i) { | ||
var const_sub_obj = {}; | ||
for (var sub_key in obj_array[i]) { | ||
addConstProperty(const_sub_obj, sub_key, obj_array[i][sub_key]); | ||
} | ||
const_obj_array.push(const_sub_obj); | ||
} | ||
addConstProperty(const_obj, key, const_obj_array); | ||
} else { | ||
addConstProperty(const_obj, key, obj[key]); | ||
} | ||
} | ||
return const_obj; | ||
} | ||
|
||
function getUniqueId() { | ||
return (unique_id++).toString(); | ||
} | ||
|
@@ -18,7 +47,7 @@ function wrapPromiseAsCallback(promise) { | |
if (error) | ||
promise.reject(error); | ||
else | ||
promise.fulfill(data); | ||
promise.fulfill(createConstClone(data)); | ||
}; | ||
}; | ||
|
||
|
@@ -205,7 +234,8 @@ var EventTargetPrototype = function() { | |
var listeners = this._event_listeners[type]; | ||
|
||
for (var i in listeners) | ||
listeners[i](new this._event_synthesizers[type](type, data)); | ||
listeners[i](new this._event_synthesizers[type](type, | ||
createConstClone(data))); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @halton , I found it failed at this line There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @legendlee1314 Do you still work on this? I think this point doesn't need to change. Just keep the old design. |
||
}; | ||
|
||
// We need a reference to the calling object because | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is right. I think it's enough for this PR's target. Can you verify it if you only change this one point?