[Service][UI] Add startService handler 76/214376/4
authorSangYong Park <sy302.park@samsung.com>
Fri, 20 Sep 2019 16:33:18 +0000 (01:33 +0900)
committerYoungsoo Choi <kenshin.choi@samsung.com>
Fri, 27 Sep 2019 02:41:03 +0000 (19:41 -0700)
This adds startService handler.

Change-Id: I9008245b9affee2faf7b04d767755445852b84ad
Signed-off-by: SangYong Park <sy302.park@samsung.com>
wrt_app/src/runtime.js

index bc07eb9..2fb132b 100755 (executable)
@@ -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)) {