From: Youngsoo Choi Date: Fri, 8 Nov 2019 02:19:02 +0000 (+0900) Subject: [Service][UI] Expose primitives and standard objects X-Git-Tag: submit/tizen_5.5/20191113.071758^2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=refs%2Fchanges%2F39%2F217239%2F10;p=platform%2Fframework%2Fweb%2Fwrtjs.git [Service][UI] Expose primitives and standard objects The primitives and standard objects are exposed to fix following undefined and type-mismatched errors: > Cannot set property 'setDate' of undefined > Cannot convert 11,21,31,71,81,91 to Uint8Array The list refers to following site: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects Change-Id: Ia4a222b0cf0c5ede3fc67ec7bf77ed435249abd0 Signed-off-by: Youngsoo Choi --- diff --git a/wrt_app/src/runtime.js b/wrt_app/src/runtime.js index 4ab808cb..7cf447bc 100644 --- a/wrt_app/src/runtime.js +++ b/wrt_app/src/runtime.js @@ -216,6 +216,19 @@ class Runtime { for(let key in timer_api) { _this.sandbox[app_id][key] = timer_api[key]; } + let standard_object_list = [ Error, EvalError, RangeError, ReferenceError, + SyntaxError, TypeError, URIError, Number, BigInt, Math, Date, + String, RegExp, Array, Int8Array, Uint8Array, Uint8ClampedArray, + Int16Array, Uint16Array, Int32Array, Uint32Array, Float32Array, + Float64Array, BigInt64Array, BigUint64Array, Map, Set, WeakMap, + WeakSet, ArrayBuffer, DataView, JSON, Promise, Reflect, Proxy, + Intl, Intl.Collator, Intl.DateTimeFormat, Intl.NumberFormat, Intl.PluralRules, + WebAssembly, WebAssembly.Module, WebAssembly.Instance, WebAssembly.Memory, + WebAssembly.Table, WebAssembly.CompileError, WebAssembly.LinkError, + WebAssembly.RuntimeError, Boolean, Function, Object, Symbol ]; + for (let idx in standard_object_list) { + _this.sandbox[app_id][standard_object_list[idx].name] = standard_object_list[idx]; + } let options = {}; let code = fs.readFileSync(params[1]); vm.runInNewContext(code, _this.sandbox[app_id], options);