1 /*
2 * Copyright (c) 2022 Huawei Device Co., Ltd.
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at
6 *
7 * http://www.apache.org/licenses/LICENSE-2.0
8 *
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
14 */
15
16 #include "napi_web_storage.h"
17
18 #include <cstddef>
19 #include <new>
20
21 #include "business_error.h"
22 #include "napi/native_common.h"
23 #include "nweb_helper.h"
24 #include "nweb_web_storage.h"
25 #include "web_errors.h"
26
27 namespace {
28 constexpr int32_t MAX_WEB_STRING_LENGTH = 40960;
29 constexpr int32_t INTERFACE_OK = 0;
30 constexpr int32_t INTERFACE_ERROR = -1;
31 constexpr int32_t RESULT_COUNT = 2;
32 constexpr int32_t PARAMZERO = 0;
33 constexpr int32_t PARAMONE = 1;
34 }
35
36 namespace OHOS {
37 namespace NWeb {
Init(napi_env env,napi_value exports)38 napi_value NapiWebStorage::Init(napi_env env, napi_value exports)
39 {
40 const std::string WEB_STORAGE_CLASS_NAME = "WebStorage";
41 napi_property_descriptor properties[] = {
42 DECLARE_NAPI_STATIC_FUNCTION("deleteAllData", NapiWebStorage::JsDeleteAllData),
43 DECLARE_NAPI_STATIC_FUNCTION("deleteOrigin", NapiWebStorage::JsDeleteOrigin),
44 DECLARE_NAPI_STATIC_FUNCTION("getOrigins", NapiWebStorage::JsGetOrigins),
45 DECLARE_NAPI_STATIC_FUNCTION("getOriginQuota", NapiWebStorage::JsGetOriginQuota),
46 DECLARE_NAPI_STATIC_FUNCTION("getOriginUsage", NapiWebStorage::JsGetOriginUsage),
47 };
48 napi_value constructor = nullptr;
49 napi_define_class(env, WEB_STORAGE_CLASS_NAME.c_str(), WEB_STORAGE_CLASS_NAME.length(), JsConstructor, nullptr,
50 sizeof(properties) / sizeof(properties[0]), properties, &constructor);
51 NAPI_ASSERT(env, constructor != nullptr, "define js class TestAsync failed");
52 napi_status status = napi_set_named_property(env, exports, "WebStorage", constructor);
53 NAPI_ASSERT(env, status == napi_ok, "set property WebStorage failed");
54 return exports;
55 }
JsDeleteAllData(napi_env env,napi_callback_info info)56 napi_value NapiWebStorage::JsDeleteAllData(napi_env env, napi_callback_info info)
57 {
58 napi_value result = nullptr;
59 OHOS::NWeb::NWebWebStorage* web_storage = OHOS::NWeb::NWebHelper::Instance().GetWebStorage();
60 if (web_storage) {
61 web_storage->DeleteAllData();
62 }
63 napi_get_undefined(env, &result);
64 return result;
65 }
66
JsDeleteOrigin(napi_env env,napi_callback_info info)67 napi_value NapiWebStorage::JsDeleteOrigin(napi_env env, napi_callback_info info)
68 {
69 napi_value retValue = nullptr;
70 size_t argc = 1;
71 napi_value argv = nullptr;
72 napi_value result = nullptr;
73 napi_get_cb_info(env, info, &argc, &argv, &retValue, nullptr);
74 if (argc != 1) {
75 NWebError::BusinessError::ThrowErrorByErrcode(env, NWebError::PARAM_CHECK_ERROR);
76 return nullptr;
77 }
78 size_t bufferSize = 0;
79 napi_valuetype valueType = napi_null;
80 napi_typeof(env, argv, &valueType);
81 if (valueType != napi_string) {
82 NWebError::BusinessError::ThrowErrorByErrcode(env, NWebError::PARAM_CHECK_ERROR);
83 return nullptr;
84 }
85 napi_get_value_string_utf8(env, argv, nullptr, 0, &bufferSize);
86 if (bufferSize >= MAX_WEB_STRING_LENGTH) {
87 NWebError::BusinessError::ThrowErrorByErrcode(env, NWebError::PARAM_CHECK_ERROR);
88 return nullptr;
89 }
90 char stringValue[bufferSize + 1];
91 size_t jsStringLength = 0;
92 napi_get_value_string_utf8(env, argv, stringValue, bufferSize + 1, &jsStringLength);
93 if (jsStringLength != bufferSize) {
94 NWebError::BusinessError::ThrowErrorByErrcode(env, NWebError::PARAM_CHECK_ERROR);
95 return nullptr;
96 }
97 std::string origin(stringValue);
98 OHOS::NWeb::NWebWebStorage* web_storage = OHOS::NWeb::NWebHelper::Instance().GetWebStorage();
99 if (web_storage) {
100 if (web_storage->DeleteOrigin(origin) == NWebError::INVALID_ORIGIN) {
101 NWebError::BusinessError::ThrowErrorByErrcode(env, NWebError::INVALID_ORIGIN);
102 return nullptr;
103 }
104 }
105 napi_get_undefined(env, &result);
106 return result;
107 }
108
GetErrorCodeValue(napi_env env,int errCode)109 napi_value NapiWebStorage::GetErrorCodeValue(napi_env env, int errCode)
110 {
111 napi_value jsObject = nullptr;
112 napi_value jsValue = nullptr;
113 NAPI_CALL(env, napi_create_int32(env, errCode, &jsValue));
114 NAPI_CALL(env, napi_create_object(env, &jsObject));
115 NAPI_CALL(env, napi_set_named_property(env, jsObject, "code", jsValue));
116 return jsObject;
117 }
118
ExecuteGetOrigins(napi_env env,void * data)119 void NapiWebStorage::ExecuteGetOrigins(napi_env env, void *data)
120 {
121 GetOriginsParam *param = reinterpret_cast<GetOriginsParam *>(data);
122 OHOS::NWeb::NWebWebStorage* web_storage = OHOS::NWeb::NWebHelper::Instance().GetWebStorage();
123 if (!web_storage) {
124 param->errCode = INTERFACE_ERROR;
125 param->status = napi_generic_failure;
126 return;
127 }
128 std::vector<OHOS::NWeb::NWebWebStorageOrigin> origins = web_storage->GetOrigins();
129 for (auto origin : origins) {
130 NapiWebStorageOrigin napiOrigin;
131 napiOrigin.origin = origin.GetOrigin();
132 napiOrigin.quota = origin.GetQuota();
133 napiOrigin.usage = origin.GetUsage();
134 param->origins.push_back(napiOrigin);
135 }
136 param->errCode = param->origins.empty() ? NWebError::NO_WEBSTORAGE_ORIGIN : INTERFACE_OK;
137 param->status = param->errCode == INTERFACE_OK ? napi_ok : napi_generic_failure;
138 }
139
GetNapiWebStorageOriginForResult(napi_env env,const std::vector<NapiWebStorageOrigin> & info,napi_value result)140 void NapiWebStorage::GetNapiWebStorageOriginForResult(napi_env env,
141 const std::vector<NapiWebStorageOrigin> &info, napi_value result)
142 {
143 int32_t index = 0;
144 for (auto item : info) {
145 napi_value napiWebStorageOrigin = nullptr;
146 napi_create_object(env, &napiWebStorageOrigin);
147
148 napi_value origin = nullptr;
149 napi_create_string_utf8(env, item.origin.c_str(), NAPI_AUTO_LENGTH, &origin);
150 napi_set_named_property(env, napiWebStorageOrigin, "origin", origin);
151
152 napi_value quota = nullptr;
153 napi_create_uint32(env, static_cast<uint32_t>(item.quota), "a);
154 napi_set_named_property(env, napiWebStorageOrigin, "quota", quota);
155
156 napi_value usage = nullptr;
157 napi_create_uint32(env, static_cast<uint32_t>(item.usage), &usage);
158 napi_set_named_property(env, napiWebStorageOrigin, "usage", usage);
159
160 napi_set_element(env, result, index, napiWebStorageOrigin);
161 index++;
162 }
163 }
164
GetOriginComplete(napi_env env,napi_status status,void * data)165 void NapiWebStorage::GetOriginComplete(napi_env env, napi_status status, void *data)
166 {
167 GetOriginsParam* param = static_cast<GetOriginsParam*>(data);
168 napi_handle_scope scope = nullptr;
169 napi_open_handle_scope(env, &scope);
170 if (scope == nullptr) {
171 return;
172 }
173 napi_value setResult[RESULT_COUNT] = {0};
174 if (param->status) {
175 setResult[PARAMZERO] = NWebError::BusinessError::CreateError(env, NWebError::NO_WEBSTORAGE_ORIGIN);
176 napi_get_undefined(env, &setResult[PARAMONE]);
177 } else {
178 napi_get_undefined(env, &setResult[PARAMZERO]);
179 napi_create_array(env, &setResult[PARAMONE]);
180 GetNapiWebStorageOriginForResult(env, param->origins, setResult[PARAMONE]);
181 }
182 napi_value args[RESULT_COUNT] = {setResult[PARAMZERO], setResult[PARAMONE]};
183 napi_value callback = nullptr;
184 napi_get_reference_value(env, param->callbackRef, &callback);
185 napi_value returnVal = nullptr;
186 napi_call_function(env, nullptr, callback, RESULT_COUNT, args, &returnVal);
187 napi_delete_reference(env, param->callbackRef);
188 napi_delete_async_work(env, param->asyncWork);
189 napi_close_handle_scope(env, scope);
190 delete param;
191 }
192
GetOriginsPromiseComplete(napi_env env,napi_status status,void * data)193 void NapiWebStorage::GetOriginsPromiseComplete(napi_env env, napi_status status, void *data)
194 {
195 GetOriginsParam* param = static_cast<GetOriginsParam*>(data);
196 napi_handle_scope scope = nullptr;
197 napi_open_handle_scope(env, &scope);
198 if (scope == nullptr) {
199 return;
200 }
201 napi_value setResult[RESULT_COUNT] = {0};
202 setResult[PARAMZERO] = NWebError::BusinessError::CreateError(env, NWebError::NO_WEBSTORAGE_ORIGIN);
203 napi_create_array(env, &setResult[PARAMONE]);
204 GetNapiWebStorageOriginForResult(env, param->origins, setResult[PARAMONE]);
205 napi_value args[RESULT_COUNT] = {setResult[PARAMZERO], setResult[PARAMONE]};
206 if (param->status == napi_ok) {
207 napi_resolve_deferred(env, param->deferred, args[1]);
208 } else {
209 napi_reject_deferred(env, param->deferred, args[0]);
210 }
211 napi_delete_async_work(env, param->asyncWork);
212 napi_close_handle_scope(env, scope);
213 delete param;
214 }
215
GetOriginsAsync(napi_env env,napi_value * argv)216 napi_value NapiWebStorage::GetOriginsAsync(napi_env env, napi_value *argv)
217 {
218 napi_value result = nullptr;
219 napi_value resourceName = nullptr;
220
221 GetOriginsParam *param = new (std::nothrow) GetOriginsParam {
222 .env = env,
223 .asyncWork = nullptr,
224 .deferred = nullptr,
225 .callbackRef = nullptr,
226 };
227 if (param == nullptr) {
228 return nullptr;
229 }
230 napi_create_reference(env, *argv, 1, ¶m->callbackRef);
231 NAPI_CALL(env, napi_create_string_utf8(env, __func__, NAPI_AUTO_LENGTH, &resourceName));
232 NAPI_CALL(env, napi_create_async_work(env, nullptr, resourceName, ExecuteGetOrigins,
233 GetOriginComplete, static_cast<void *>(param), ¶m->asyncWork));
234 NAPI_CALL(env, napi_queue_async_work(env, param->asyncWork));
235 napi_get_undefined(env, &result);
236 return result;
237 }
238
GetOriginsPromise(napi_env env)239 napi_value NapiWebStorage::GetOriginsPromise(napi_env env)
240 {
241 napi_deferred deferred = nullptr;
242 napi_value promise = nullptr;
243 napi_create_promise(env, &deferred, &promise);
244
245 GetOriginsParam *param = new (std::nothrow) GetOriginsParam {
246 .env = env,
247 .asyncWork = nullptr,
248 .deferred = deferred,
249 .callbackRef = nullptr,
250 };
251 if (param == nullptr) {
252 return nullptr;
253 }
254 napi_value resourceName = nullptr;
255 NAPI_CALL(env, napi_create_string_utf8(env, __func__, NAPI_AUTO_LENGTH, &resourceName));
256 NAPI_CALL(env, napi_create_async_work(env, nullptr, resourceName, ExecuteGetOrigins,
257 GetOriginsPromiseComplete, static_cast<void *>(param), ¶m->asyncWork));
258 NAPI_CALL(env, napi_queue_async_work(env, param->asyncWork));
259 return promise;
260 }
261
JsGetOrigins(napi_env env,napi_callback_info info)262 napi_value NapiWebStorage::JsGetOrigins(napi_env env, napi_callback_info info)
263 {
264 napi_value retValue = nullptr;
265 size_t argc = 0;
266 size_t argcPromise = 0;
267 size_t argcCallback = 1;
268 napi_value argv = nullptr;
269 napi_value result = nullptr;
270 napi_get_undefined(env, &result);
271 napi_get_cb_info(env, info, &argc, &argv, &retValue, nullptr);
272 if (argc != argcPromise && argc != argcCallback) {
273 NWebError::BusinessError::ThrowErrorByErrcode(env, NWebError::PARAM_CHECK_ERROR);
274 return nullptr;
275 }
276 if (argc == argcCallback) {
277 napi_valuetype valueType = napi_undefined;
278 napi_get_cb_info(env, info, &argc, &argv, &retValue, nullptr);
279 napi_typeof(env, argv, &valueType);
280 if (valueType != napi_function) {
281 NWebError::BusinessError::ThrowErrorByErrcode(env, NWebError::PARAM_CHECK_ERROR);
282 return nullptr;
283 }
284 return GetOriginsAsync(env, &argv);
285 }
286 return GetOriginsPromise(env);
287 }
288
ExecuteGetOriginUsageOrQuota(napi_env env,void * data)289 void NapiWebStorage::ExecuteGetOriginUsageOrQuota(napi_env env, void *data)
290 {
291 GetOriginUsageOrQuotaParam *param = reinterpret_cast<GetOriginUsageOrQuotaParam *>(data);
292 OHOS::NWeb::NWebWebStorage* web_storage = OHOS::NWeb::NWebHelper::Instance().GetWebStorage();
293 if (!web_storage) {
294 param->errCode = INTERFACE_ERROR;
295 param->status = napi_generic_failure;
296 return;
297 }
298 if (param->isQuato) {
299 param->retValue = web_storage->GetOriginQuota(param->origin);
300 if (param->retValue != INTERFACE_ERROR && param->retValue != NWebError::INVALID_ORIGIN) {
301 param->errCode = INTERFACE_OK;
302 } else {
303 param->errCode = param->retValue;
304 }
305 param->status = param->errCode == INTERFACE_OK ? napi_ok : napi_generic_failure;
306 return;
307 }
308 param->retValue = web_storage->GetOriginUsage(param->origin);
309 if (param->retValue != INTERFACE_ERROR && param->retValue != NWebError::INVALID_ORIGIN) {
310 param->errCode = INTERFACE_OK;
311 } else {
312 param->errCode = param->retValue;
313 }
314 param->status = param->errCode == INTERFACE_OK ? napi_ok : napi_generic_failure;
315 }
316
GetOriginUsageOrQuotaComplete(napi_env env,napi_status status,void * data)317 void NapiWebStorage::GetOriginUsageOrQuotaComplete(napi_env env, napi_status status, void *data)
318 {
319 GetOriginUsageOrQuotaParam* param = static_cast<GetOriginUsageOrQuotaParam*>(data);
320 napi_handle_scope scope = nullptr;
321 napi_open_handle_scope(env, &scope);
322 if (scope == nullptr) {
323 return;
324 }
325 napi_value setResult[RESULT_COUNT] = {0};
326 if (param->status) {
327 if (param->errCode == NWebError::INVALID_ORIGIN) {
328 setResult[PARAMZERO] = NWebError::BusinessError::CreateError(env, NWebError::INVALID_ORIGIN);
329 } else {
330 napi_get_undefined(env, &setResult[PARAMZERO]);
331 }
332 napi_get_undefined(env, &setResult[PARAMONE]);
333 } else {
334 napi_get_undefined(env, &setResult[PARAMZERO]);
335 napi_create_array(env, &setResult[PARAMONE]);
336 napi_create_uint32(env, static_cast<uint32_t>(param->retValue), &setResult[PARAMONE]);
337 }
338 napi_value args[RESULT_COUNT] = {setResult[PARAMZERO], setResult[PARAMONE]};
339 napi_value callback = nullptr;
340 napi_get_reference_value(env, param->callbackRef, &callback);
341 napi_value returnVal = nullptr;
342 napi_call_function(env, nullptr, callback, RESULT_COUNT, &args[PARAMZERO], &returnVal);
343 napi_delete_reference(env, param->jsStringRef);
344 napi_delete_reference(env, param->callbackRef);
345 napi_delete_async_work(env, param->asyncWork);
346 napi_close_handle_scope(env, scope);
347 delete param;
348 }
349
GetOriginUsageOrQuotaPromiseComplete(napi_env env,napi_status status,void * data)350 void NapiWebStorage::GetOriginUsageOrQuotaPromiseComplete(napi_env env, napi_status status, void *data)
351 {
352 GetOriginUsageOrQuotaParam* param = static_cast<GetOriginUsageOrQuotaParam*>(data);
353 napi_handle_scope scope = nullptr;
354 napi_open_handle_scope(env, &scope);
355 if (scope == nullptr) {
356 return;
357 }
358 napi_value setResult[RESULT_COUNT] = {0};
359 setResult[PARAMZERO] = NWebError::BusinessError::CreateError(env, NWebError::INVALID_ORIGIN);
360 napi_create_uint32(env, static_cast<uint32_t>(param->retValue), &setResult[PARAMONE]);
361 napi_value args[RESULT_COUNT] = {setResult[PARAMZERO], setResult[PARAMONE]};
362 if (param->status != napi_ok && param->errCode == NWebError::INVALID_ORIGIN) {
363 napi_reject_deferred(env, param->deferred, args[PARAMZERO]);
364 } else {
365 napi_resolve_deferred(env, param->deferred, args[PARAMONE]);
366 }
367 napi_delete_reference(env, param->jsStringRef);
368 napi_delete_async_work(env, param->asyncWork);
369 napi_close_handle_scope(env, scope);
370 delete param;
371 }
372
GetOriginUsageOrQuotaAsync(napi_env env,napi_value * argv,const std::string & origin,bool isQuato)373 napi_value NapiWebStorage::GetOriginUsageOrQuotaAsync(napi_env env,
374 napi_value *argv, const std::string& origin, bool isQuato)
375 {
376 napi_value result = nullptr;
377 napi_value resourceName = nullptr;
378
379 GetOriginUsageOrQuotaParam *param = new (std::nothrow) GetOriginUsageOrQuotaParam {
380 .retValue = -1,
381 .isQuato = isQuato,
382 .origin = origin,
383 .jsStringRef = nullptr,
384 .env = env,
385 .asyncWork = nullptr,
386 .deferred = nullptr,
387 .callbackRef = nullptr,
388 };
389 if (param == nullptr) {
390 return nullptr;
391 }
392 napi_create_reference(env, argv[PARAMZERO], 1, ¶m->jsStringRef);
393 napi_create_reference(env, argv[PARAMONE], 1, ¶m->callbackRef);
394 NAPI_CALL(env, napi_create_string_utf8(env, __func__, NAPI_AUTO_LENGTH, &resourceName));
395 NAPI_CALL(env, napi_create_async_work(env, nullptr, resourceName, ExecuteGetOriginUsageOrQuota,
396 GetOriginUsageOrQuotaComplete, static_cast<void *>(param), ¶m->asyncWork));
397 NAPI_CALL(env, napi_queue_async_work(env, param->asyncWork));
398 napi_get_undefined(env, &result);
399 return result;
400 }
401
GetOriginUsageOrQuotaPromise(napi_env env,napi_value * argv,const std::string & origin,bool isQuato)402 napi_value NapiWebStorage::GetOriginUsageOrQuotaPromise(napi_env env,
403 napi_value *argv, const std::string& origin, bool isQuato)
404 {
405 napi_deferred deferred = nullptr;
406 napi_value promise = nullptr;
407 napi_create_promise(env, &deferred, &promise);
408
409 GetOriginUsageOrQuotaParam *param = new (std::nothrow) GetOriginUsageOrQuotaParam {
410 .retValue = -1,
411 .isQuato = isQuato,
412 .origin = origin,
413 .jsStringRef = nullptr,
414 .env = env,
415 .asyncWork = nullptr,
416 .deferred = deferred,
417 .callbackRef = nullptr,
418 };
419 if (param == nullptr) {
420 return nullptr;
421 }
422 napi_create_reference(env, argv[PARAMZERO], 1, ¶m->jsStringRef);
423 napi_value resourceName = nullptr;
424 NAPI_CALL(env, napi_create_string_utf8(env, __func__, NAPI_AUTO_LENGTH, &resourceName));
425 NAPI_CALL(env, napi_create_async_work(env, nullptr, resourceName, ExecuteGetOriginUsageOrQuota,
426 GetOriginUsageOrQuotaPromiseComplete, static_cast<void *>(param), ¶m->asyncWork));
427 NAPI_CALL(env, napi_queue_async_work(env, param->asyncWork));
428 return promise;
429 }
430
JsGetOriginUsageOrQuota(napi_env env,napi_callback_info info,bool isQuato)431 napi_value NapiWebStorage::JsGetOriginUsageOrQuota(napi_env env, napi_callback_info info, bool isQuato)
432 {
433 napi_value retValue = nullptr;
434 size_t argc = 1;
435 size_t argcPromise = 1;
436 size_t argcCallback = 2;
437 napi_value argv[RESULT_COUNT] = {0};
438 napi_get_cb_info(env, info, &argc, argv, &retValue, nullptr);
439 if (argc != argcPromise && argc != argcCallback) {
440 NWebError::BusinessError::ThrowErrorByErrcode(env, NWebError::PARAM_CHECK_ERROR);
441 return nullptr;
442 }
443 napi_valuetype valueType = napi_null;
444 napi_typeof(env, argv[PARAMZERO], &valueType);
445 if (valueType != napi_string) {
446 NWebError::BusinessError::ThrowErrorByErrcode(env, NWebError::PARAM_CHECK_ERROR);
447 return nullptr;
448 }
449 size_t bufferSize = 0;
450 napi_get_value_string_utf8(env, argv[PARAMZERO], nullptr, 0, &bufferSize);
451 if (bufferSize >= MAX_WEB_STRING_LENGTH) {
452 NWebError::BusinessError::ThrowErrorByErrcode(env, NWebError::PARAM_CHECK_ERROR);
453 return nullptr;
454 }
455 char stringValue[bufferSize + 1];
456 size_t jsStringLength = 0;
457 napi_get_value_string_utf8(env, argv[PARAMZERO], stringValue, bufferSize + 1, &jsStringLength);
458 if (jsStringLength != bufferSize) {
459 NWebError::BusinessError::ThrowErrorByErrcode(env, NWebError::PARAM_CHECK_ERROR);
460 return nullptr;
461 }
462 std::string origin(stringValue);
463 if (argc == argcCallback) {
464 valueType = napi_undefined;
465 napi_get_cb_info(env, info, &argc, argv, &retValue, nullptr);
466 napi_typeof(env, argv[argcCallback - 1], &valueType);
467 if (valueType != napi_function) {
468 NWebError::BusinessError::ThrowErrorByErrcode(env, NWebError::PARAM_CHECK_ERROR);
469 return nullptr;
470 }
471 return GetOriginUsageOrQuotaAsync(env, argv, origin, isQuato);
472 }
473 return GetOriginUsageOrQuotaPromise(env, argv, origin, isQuato);
474 }
475
JsGetOriginQuota(napi_env env,napi_callback_info info)476 napi_value NapiWebStorage::JsGetOriginQuota(napi_env env, napi_callback_info info)
477 {
478 return JsGetOriginUsageOrQuota(env, info, true);
479 }
480
JsGetOriginUsage(napi_env env,napi_callback_info info)481 napi_value NapiWebStorage::JsGetOriginUsage(napi_env env, napi_callback_info info)
482 {
483 return JsGetOriginUsageOrQuota(env, info, false);
484 }
485
JsConstructor(napi_env env,napi_callback_info info)486 napi_value NapiWebStorage::JsConstructor(napi_env env, napi_callback_info info)
487 {
488 napi_value thisVar = nullptr;
489 size_t argc = 2;
490 napi_value argv[RESULT_COUNT] = {0};
491 napi_get_cb_info(env, info, &argc, argv, &thisVar, nullptr);
492 return thisVar;
493 }
494 } // namespace NWeb
495 } // namespace OHOS
496