From: SangYong Park Date: Fri, 20 Sep 2019 16:33:18 +0000 (+0900) Subject: [Service][UI] Add startService handler X-Git-Tag: accepted/tizen/unified/20191002.013355~1^2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=db7f5e64147a9b0881f00757db512681b0be73d5;p=platform%2Fframework%2Fweb%2Fwrtjs.git [Service][UI] Add startService handler This adds startService handler. Change-Id: I9008245b9affee2faf7b04d767755445852b84ad Signed-off-by: SangYong Park --- diff --git a/wrt_app/src/runtime.js b/wrt_app/src/runtime.js index bc07eb9..2fb132b 100755 --- a/wrt_app/src/runtime.js +++ b/wrt_app/src/runtime.js @@ -176,6 +176,22 @@ class Runtime { if (_this.webApplication) _this.webApplication.lowMemory(); }); + wrt.on('message', function(event, type, params) { + console.log('message type(' + type + ') params : ' + params); + if (type === 'startService') { + const vm = require('vm'); + const fs = require('fs'); + let sandbox = { + console: console, + module: module, + require: require, + }; + let options = {}; + let code = fs.readFileSync(params[1]); + vm.runInNewContext(code, sandbox, options); + event.preventDefault(); + } + }); wrt.on('wgt-installed', function(event, path) { console.log('wgt-installed at ' + path); if (AddonManager.isAddon(path)) {