From: Youngsoo Choi Date: Tue, 26 Nov 2019 04:42:42 +0000 (-0800) Subject: [Service][Global] Expose standard and global objects X-Git-Tag: submit/tizen_5.5/20200109.070620~3^2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=refs%2Fchanges%2F09%2F218609%2F8;p=platform%2Fframework%2Fweb%2Fwrtjs.git [Service][Global] Expose standard and global objects This enables functions and properties of global object, such as setInterval, setTimeout, and etc in service apps. Also, 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: I61977e05b73b3817b75591d2c8b0bb708f175c8d Signed-off-by: Youngsoo Choi --- diff --git a/wrt_app/service/main.js b/wrt_app/service/main.js index 2098ad58..9713ffb9 100755 --- a/wrt_app/service/main.js +++ b/wrt_app/service/main.js @@ -32,6 +32,22 @@ wrt.on('start-service', (event, app_id) => { require: require, tizen: tizen, }; + for(let key in global) { + sandbox[app_id][key] = global[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) { + sandbox[app_id][standard_object_list[idx].name] = standard_object_list[idx]; + } let options = { filename: app_id }; vm.runInNewContext(wrt.readService(app_id), sandbox[app_id], options);