Add 'self' as global scope for web worker 75/272175/1
authorDongHyun Song <dh81.song@samsung.com>
Tue, 8 Mar 2022 08:35:55 +0000 (17:35 +0900)
committerPiotr Kosko <p.kosko@samsung.com>
Thu, 10 Mar 2022 10:20:16 +0000 (10:20 +0000)
In web worker world, 'self' is defined global scope object.
This change is necessary to apply tizen webapis on web worker for
specific purpose. (i.e. tizen.ml)

Change-Id: Ie9602ea4f492589dad2c87e3c0bd8e2602278c02
Signed-off-by: DongHyun Song <dh81.song@samsung.com>
(cherry picked from commit 937fc3e4fd8c9a3dd32974a4e261d82e4db31b73)

src/utils/utils_api.js

index 5f7b478..7d184af 100644 (file)
@@ -11,10 +11,12 @@ exports.JSON = JSON_;
 var _enableJsLogs = false;
 
 var _global = {};
-if (typeof window != 'undefined') {
+if (typeof window !== 'undefined') {
     _global = window;
-} else if (typeof global != 'undefined') {
+} else if (typeof global !== 'undefined') {
     _global = global;
+} else if (typeof self !== 'undefined') {
+    _global = self;
 }
 
 /**
@@ -1655,6 +1657,8 @@ if (typeof window !== 'undefined') {
     scope = window;
 } else if (typeof global !== 'undefined') {
     scope = global;
+} else if (typeof self !== 'undefined') {
+    scope = self;
 }
 scope = scope || {};
 scope.WebAPIException = WebAPIException;