Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Xts Acts
提交
e773db36
X
Xts Acts
项目概览
OpenHarmony
/
Xts Acts
1 年多 前同步成功
通知
9
Star
22
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
X
Xts Acts
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
未验证
提交
e773db36
编写于
1月 17, 2022
作者:
O
openharmony_ci
提交者:
Gitee
1月 17, 2022
浏览文件
操作
浏览文件
下载
差异文件
!1495 add second worker xts testcase
Merge pull request !1495 from yaojian16/master
上级
b6dc84b1
fb04d89b
变更
28
显示空白变更内容
内联
并排
Showing
28 changed file
with
1516 addition
and
929 deletion
+1516
-929
compileruntime/BUILD.gn
compileruntime/BUILD.gn
+1
-2
compileruntime/worker_lib_standard/src/main/config.json
compileruntime/worker_lib_standard/src/main/config.json
+4
-0
compileruntime/worker_lib_standard/src/main/js/default/workers/worker.js
...worker_lib_standard/src/main/js/default/workers/worker.js
+56
-66
compileruntime/worker_lib_standard/src/main/js/default/workers/worker_002.js
...er_lib_standard/src/main/js/default/workers/worker_002.js
+23
-32
compileruntime/worker_lib_standard/src/main/js/default/workers/worker_003.js
...er_lib_standard/src/main/js/default/workers/worker_003.js
+22
-30
compileruntime/worker_lib_standard/src/main/js/default/workers/worker_004.js
...er_lib_standard/src/main/js/default/workers/worker_004.js
+23
-31
compileruntime/worker_lib_standard/src/main/js/default/workers/worker_005.js
...er_lib_standard/src/main/js/default/workers/worker_005.js
+21
-29
compileruntime/worker_lib_standard/src/main/js/default/workers/worker_006.js
...er_lib_standard/src/main/js/default/workers/worker_006.js
+21
-29
compileruntime/worker_lib_standard/src/main/js/default/workers/worker_007.js
...er_lib_standard/src/main/js/default/workers/worker_007.js
+21
-29
compileruntime/worker_lib_standard/src/main/js/default/workers/worker_008.js
...er_lib_standard/src/main/js/default/workers/worker_008.js
+21
-29
compileruntime/worker_lib_standard/src/main/js/default/workers/worker_009.js
...er_lib_standard/src/main/js/default/workers/worker_009.js
+32
-0
compileruntime/worker_lib_standard/src/main/js/default/workers/worker_0091.js
...r_lib_standard/src/main/js/default/workers/worker_0091.js
+5
-9
compileruntime/worker_lib_standard/src/main/js/default/workers/worker_010.js
...er_lib_standard/src/main/js/default/workers/worker_010.js
+42
-0
compileruntime/worker_lib_standard/src/main/js/default/workers/worker_0101.js
...r_lib_standard/src/main/js/default/workers/worker_0101.js
+22
-0
compileruntime/worker_lib_standard/src/main/js/default/workers/worker_011.js
...er_lib_standard/src/main/js/default/workers/worker_011.js
+50
-0
compileruntime/worker_lib_standard/src/main/js/default/workers/worker_0111.js
...r_lib_standard/src/main/js/default/workers/worker_0111.js
+22
-0
compileruntime/worker_lib_standard/src/main/js/default/workers/worker_012.js
...er_lib_standard/src/main/js/default/workers/worker_012.js
+42
-0
compileruntime/worker_lib_standard/src/main/js/default/workers/worker_0121.js
...r_lib_standard/src/main/js/default/workers/worker_0121.js
+33
-0
compileruntime/worker_lib_standard/src/main/js/default/workers/worker_0122.js
...r_lib_standard/src/main/js/default/workers/worker_0122.js
+25
-0
compileruntime/worker_lib_standard/src/main/js/default/workers/worker_013.js
...er_lib_standard/src/main/js/default/workers/worker_013.js
+42
-0
compileruntime/worker_lib_standard/src/main/js/default/workers/worker_0131.js
...r_lib_standard/src/main/js/default/workers/worker_0131.js
+22
-0
compileruntime/worker_lib_standard/src/main/js/default/workers/worker_014.js
...er_lib_standard/src/main/js/default/workers/worker_014.js
+42
-0
compileruntime/worker_lib_standard/src/main/js/default/workers/worker_0141.js
...r_lib_standard/src/main/js/default/workers/worker_0141.js
+23
-0
compileruntime/worker_lib_standard/src/main/js/default/workers/worker_015.js
...er_lib_standard/src/main/js/default/workers/worker_015.js
+43
-0
compileruntime/worker_lib_standard/src/main/js/default/workers/worker_0151.js
...r_lib_standard/src/main/js/default/workers/worker_0151.js
+42
-0
compileruntime/worker_lib_standard/src/main/js/default/workers/worker_0152.js
...r_lib_standard/src/main/js/default/workers/worker_0152.js
+22
-0
compileruntime/worker_lib_standard/src/main/js/test/List.test.js
...runtime/worker_lib_standard/src/main/js/test/List.test.js
+15
-16
compileruntime/worker_lib_standard/src/main/js/test/Worker.test.js
...ntime/worker_lib_standard/src/main/js/test/Worker.test.js
+779
-627
未找到文件。
compileruntime/BUILD.gn
浏览文件 @
e773db36
...
...
@@ -21,9 +21,8 @@ group("compileruntime") {
"uri_lib_standard:uri_js_test",
"url_lib_standard:url_js_test",
"util_lib_standard:util_js_test",
"worker_lib_standard:worker_js_hap",
"xml_lib_standard:xml_js_test",
# "worker_lib_standard:worker_js_hap",
]
}
}
compileruntime/worker_lib_standard/src/main/config.json
浏览文件 @
e773db36
...
...
@@ -5,6 +5,10 @@
"version"
:
{
"code"
:
1000000
,
"name"
:
"1.0.0"
},
"apiVersion"
:
{
"compatible"
:
4
,
"target"
:
5
}
},
"deviceConfig"
:
{},
...
...
compileruntime/worker_lib_standard/src/main/js/default/workers/worker.js
浏览文件 @
e773db36
...
...
@@ -13,24 +13,16 @@
* limitations under the License.
*/
/******/
(()
=>
{
// webpackBootstrap
var
__webpack_exports__
=
{};
/*!********************************************************************************************!*\
!*** d:\workspace\my_works\MyApplication\entry\src\main\ets\default\workers\WorkerDemo.js ***!
\********************************************************************************************/
function
foo
(
x
)
{
return
x
}
import
worker
from
'
@ohos.worker
'
;
const
parentPort
=
worker
.
parentPort
;
var
worker
=
globalThis
.
requireNapi
(
'
worker
'
);
console
.
info
(
"
worker:: new version
"
)
const
parentPort
=
worker
.
parentPort
;
console
.
info
(
"
worker:: new version
"
)
parentPort
.
onclose
=
function
()
{
parentPort
.
onclose
=
function
()
{
console
.
info
(
"
worker::worker.js onclose
"
);
}
}
parentPort
.
onmessage
=
function
(
e
)
{
parentPort
.
onmessage
=
function
(
e
)
{
var
data
=
e
.
data
;
console
.
info
(
"
worker:: worker thread worker data is
"
+
data
.
data
);
switch
(
data
.
type
)
{
...
...
@@ -51,16 +43,14 @@
console
.
info
(
"
worker:: worker.js receive unknow type
"
);
break
}
}
}
// 反序列错误
parentPort
.
onmessageerror
=
function
()
{
// 反序列错误
parentPort
.
onmessageerror
=
function
()
{
console
.
info
(
"
worker:: worker.js onmessageerror
"
);
}
}
// js执行异常
parentPort
.
onerror
=
function
(
data
)
{
// js执行异常
parentPort
.
onerror
=
function
(
data
)
{
console
.
info
(
"
worker:: worker.js onerror
"
+
data
.
lineno
+
"
, msg =
"
+
data
.
message
+
"
, filename =
"
+
data
.
filename
+
"
, colno =
"
+
data
.
colno
);
}
/******/
})()
;
\ No newline at end of file
}
\ No newline at end of file
compileruntime/worker_lib_standard/src/main/js/default/workers/worker_002.js
浏览文件 @
e773db36
...
...
@@ -13,20 +13,11 @@
* limitations under the License.
*/
/******/
(()
=>
{
// webpackBootstrap
var
__webpack_exports__
=
{};
/*!********************************************************************************************!*\
!*** d:\workspace\my_works\MyApplication\entry\src\main\ets\default\workers\WorkerDemo.js ***!
\********************************************************************************************/
console
.
log
(
"
worker:: run script
"
);
var
worker
=
globalThis
.
requireNapi
(
'
worker
'
);
import
worker
from
'
@ohos.worker
'
;
const
parentPort
=
worker
.
parentPort
;
const
parentPort
=
worker
.
parentPort
;
parentPort
.
onmessage
=
function
(
e
)
{
parentPort
.
onmessage
=
function
(
e
)
{
console
.
log
(
"
worker:: worker receive data
"
+
e
.
data
);
var
data
=
e
.
data
+
"
worker
"
;
parentPort
.
postMessage
(
data
)
}
/******/
})()
;
\ No newline at end of file
}
\ No newline at end of file
compileruntime/worker_lib_standard/src/main/js/default/workers/worker_003.js
浏览文件 @
e773db36
...
...
@@ -13,18 +13,10 @@
* limitations under the License.
*/
/******/
(()
=>
{
// webpackBootstrap
var
__webpack_exports__
=
{};
/*!********************************************************************************************!*\
!*** d:\workspace\my_works\MyApplication\entry\src\main\ets\default\workers\WorkerDemo.js ***!
\********************************************************************************************/
var
worker
=
globalThis
.
requireNapi
(
'
worker
'
);
import
worker
from
'
@ohos.worker
'
;
const
parentPort
=
worker
.
parentPort
;
const
parentPort
=
worker
.
parentPort
;
parentPort
.
onmessage
=
function
(
e
)
{
parentPort
.
onmessage
=
function
(
e
)
{
var
data
=
e
.
data
*
2
+
1
parentPort
.
postMessage
(
data
)
}
/******/
})()
;
\ No newline at end of file
}
\ No newline at end of file
compileruntime/worker_lib_standard/src/main/js/default/workers/worker_004.js
浏览文件 @
e773db36
...
...
@@ -13,19 +13,11 @@
* limitations under the License.
*/
/******/
(()
=>
{
// webpackBootstrap
var
__webpack_exports__
=
{};
/*!********************************************************************************************!*\
!*** d:\workspace\my_works\MyApplication\entry\src\main\ets\default\workers\WorkerDemo.js ***!
\********************************************************************************************/
var
worker
=
globalThis
.
requireNapi
(
'
worker
'
);
import
worker
from
'
@ohos.worker
'
;
const
parentPort
=
worker
.
parentPort
;
const
parentPort
=
worker
.
parentPort
;
parentPort
.
onmessage
=
function
(
e
)
{
parentPort
.
onmessage
=
function
(
e
)
{
var
data
=
e
.
data
;
data
.
message
=
"
hello world
"
+
"
worker
"
parentPort
.
postMessage
(
data
)
}
/******/
})()
;
\ No newline at end of file
}
\ No newline at end of file
compileruntime/worker_lib_standard/src/main/js/default/workers/worker_005.js
浏览文件 @
e773db36
...
...
@@ -13,17 +13,9 @@
* limitations under the License.
*/
/******/
(()
=>
{
// webpackBootstrap
var
__webpack_exports__
=
{};
/*!********************************************************************************************!*\
!*** d:\workspace\my_works\MyApplication\entry\src\main\ets\default\workers\WorkerDemo.js ***!
\********************************************************************************************/
var
worker
=
globalThis
.
requireNapi
(
'
worker
'
);
import
worker
from
'
@ohos.worker
'
;
const
parentPort
=
worker
.
parentPort
;
const
parentPort
=
worker
.
parentPort
;
parentPort
.
onmessage
=
function
(
e
)
{
parentPort
.
onmessage
=
function
(
e
)
{
parentPort
.
postMessage
(
name
)
}
/******/
})()
;
\ No newline at end of file
}
\ No newline at end of file
compileruntime/worker_lib_standard/src/main/js/default/workers/worker_006.js
浏览文件 @
e773db36
...
...
@@ -13,17 +13,9 @@
* limitations under the License.
*/
/******/
(()
=>
{
// webpackBootstrap
var
__webpack_exports__
=
{};
/*!********************************************************************************************!*\
!*** d:\workspace\my_works\MyApplication\entry\src\main\ets\default\workers\WorkerDemo.js ***!
\********************************************************************************************/
var
worker
=
globalThis
.
requireNapi
(
'
worker
'
);
import
worker
from
'
@ohos.worker
'
;
const
parentPort
=
worker
.
parentPort
;
const
parentPort
=
worker
.
parentPort
;
parentPort
.
onmessage
=
function
(
e
)
{
parentPort
.
onmessage
=
function
(
e
)
{
parentPort
.
postMessage
(
"
hello world
"
)
}
/******/
})()
;
\ No newline at end of file
}
\ No newline at end of file
compileruntime/worker_lib_standard/src/main/js/default/workers/worker_007.js
浏览文件 @
e773db36
...
...
@@ -13,17 +13,9 @@
* limitations under the License.
*/
/******/
(()
=>
{
// webpackBootstrap
var
__webpack_exports__
=
{};
/*!********************************************************************************************!*\
!*** d:\workspace\my_works\MyApplication\entry\src\main\ets\default\workers\WorkerDemo.js ***!
\********************************************************************************************/
var
worker
=
globalThis
.
requireNapi
(
'
worker
'
);
import
worker
from
'
@ohos.worker
'
;
const
parentPort
=
worker
.
parentPort
;
const
parentPort
=
worker
.
parentPort
;
parentPort
.
onmessage
=
function
(
e
)
{
parentPort
.
onmessage
=
function
(
e
)
{
throw
new
Error
(
123
)
}
/******/
})()
;
\ No newline at end of file
}
\ No newline at end of file
compileruntime/worker_lib_standard/src/main/js/default/workers/worker_008.js
浏览文件 @
e773db36
...
...
@@ -13,17 +13,9 @@
* limitations under the License.
*/
/******/
(()
=>
{
// webpackBootstrap
var
__webpack_exports__
=
{};
/*!********************************************************************************************!*\
!*** d:\workspace\my_works\MyApplication\entry\src\main\ets\default\workers\WorkerDemo.js ***!
\********************************************************************************************/
var
worker
=
globalThis
.
requireNapi
(
'
worker
'
);
import
worker
from
'
@ohos.worker
'
;
const
parentPort
=
worker
.
parentPort
;
const
parentPort
=
worker
.
parentPort
;
parentPort
.
onmessage
=
function
(
e
)
{
parentPort
.
onmessage
=
function
(
e
)
{
parentPort
.
close
()
}
/******/
})()
;
\ No newline at end of file
}
compileruntime/worker_lib_standard/src/main/js/default/workers/worker_009.js
0 → 100644
浏览文件 @
e773db36
/*
* Copyright (C) 2021 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import
worker
from
"
@ohos.worker
"
const
parentPort
=
worker
.
parentPort
;
var
ss
=
undefined
;
parentPort
.
onmessage
=
function
(
e
)
{
var
data
=
e
.
data
;
switch
(
data
.
type
)
{
case
"
new
"
:
ss
=
new
worker
.
Worker
(
"
workers/worker_0091.js
"
);
console
.
log
(
"
worker:: workerxx
"
);
parentPort
.
postMessage
(
ss
!=
null
);
break
;
default
:
break
;
}
}
\ No newline at end of file
compileruntime/worker_lib_standard/src/main/js/
test/ExampleJsunit.test
.js
→
compileruntime/worker_lib_standard/src/main/js/
default/workers/worker_0091
.js
浏览文件 @
e773db36
...
...
@@ -12,14 +12,10 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import
worker
from
"
@ohos.worker
"
import
app
from
'
@system.app
'
import
{
describe
,
beforeAll
,
beforeEach
,
afterEach
,
afterAll
,
it
,
expect
}
from
'
deccjsunit/index
'
const
parentPort
=
worker
.
parentPort
;
describe
(
'
appInfoTest
'
,
function
()
{
it
(
'
app_info_test_001
'
,
0
,
function
()
{
var
info
=
app
.
getInfo
()
expect
(
info
.
versionName
).
assertEqual
(
'
1.0.0
'
)
expect
(
info
.
versionCode
).
assertEqual
(
'
1000000
'
)
})
})
\ No newline at end of file
parentPort
.
onmessage
=
function
(
e
)
{
console
.
log
(
"
worker:: onmessage
"
);
}
\ No newline at end of file
compileruntime/worker_lib_standard/src/main/js/default/workers/worker_010.js
0 → 100644
浏览文件 @
e773db36
/*
* Copyright (C) 2021 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import
worker
from
"
@ohos.worker
"
const
parentPort
=
worker
.
parentPort
;
var
ss
=
undefined
;
var
backValue
=
undefined
;
var
flag
=
false
;
parentPort
.
onmessage
=
function
(
e
)
{
var
data
=
e
.
data
;
switch
(
data
.
type
)
{
case
"
new
"
:
ss
=
new
worker
.
Worker
(
"
workers/worker_0101.js
"
);
ss
.
onmessage
=
function
(
ee
)
{
backValue
=
ee
.
data
;
flag
=
true
;
}
ss
.
postMessage
(
data
.
value
);
break
;
case
"
wait
"
:
if
(
flag
)
{
parentPort
.
postMessage
(
backValue
);
}
break
;
default
:
break
;
}
}
\ No newline at end of file
compileruntime/worker_lib_standard/src/main/js/default/workers/worker_0101.js
0 → 100644
浏览文件 @
e773db36
/*
* Copyright (C) 2021 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import
worker
from
"
@ohos.worker
"
const
parentPort
=
worker
.
parentPort
;
parentPort
.
onmessage
=
function
(
e
)
{
var
data
=
e
.
data
;
// 12
parentPort
.
postMessage
(
data
*
2
+
1
);
// 25
}
\ No newline at end of file
compileruntime/worker_lib_standard/src/main/js/default/workers/worker_011.js
0 → 100644
浏览文件 @
e773db36
/*
* Copyright (C) 2021 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import
worker
from
"
@ohos.worker
"
const
parentPort
=
worker
.
parentPort
;
var
ss
=
undefined
;
var
backValue
=
undefined
;
var
flag
=
false
;
parentPort
.
onmessage
=
function
(
e
)
{
var
data
=
e
.
data
;
switch
(
data
.
type
)
{
case
"
new
"
:
ss
=
new
worker
.
Worker
(
"
workers/worker_0111.js
"
);
ss
.
onmessage
=
function
(
ee
)
{
backValue
=
ee
.
data
;
flag
=
true
;
}
ss
.
onexit
=
function
(
code
)
{
backValue
=
"
terminate
"
;
flag
=
true
;
}
ss
.
postMessage
(
data
.
value
);
break
;
case
"
wait
"
:
if
(
flag
)
{
parentPort
.
postMessage
(
backValue
);
}
break
;
case
"
terminate
"
:
flag
=
false
;
ss
.
terminate
();
break
;
default
:
break
;
}
}
\ No newline at end of file
compileruntime/worker_lib_standard/src/main/js/default/workers/worker_0111.js
0 → 100644
浏览文件 @
e773db36
/*
* Copyright (C) 2021 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import
worker
from
"
@ohos.worker
"
const
parentPort
=
worker
.
parentPort
;
parentPort
.
onmessage
=
function
(
e
)
{
console
.
log
(
"
worker:: onmessage
"
)
parentPort
.
postMessage
(
"
terminate
"
);
}
\ No newline at end of file
compileruntime/worker_lib_standard/src/main/js/default/workers/worker_012.js
0 → 100644
浏览文件 @
e773db36
/*
* Copyright (C) 2021 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import
worker
from
"
@ohos.worker
"
const
parentPort
=
worker
.
parentPort
;
var
ss
=
undefined
;
var
backValue
=
undefined
;
var
flag
=
false
;
parentPort
.
onmessage
=
function
(
e
)
{
var
data
=
e
.
data
;
switch
(
data
.
type
)
{
case
"
new
"
:
ss
=
new
worker
.
Worker
(
"
workers/worker_0121.js
"
);
ss
.
onmessage
=
function
(
ee
)
{
backValue
=
ee
.
data
;
flag
=
true
;
}
ss
.
postMessage
({
type
:
"
new
"
});
break
;
case
"
wait
"
:
if
(
flag
)
{
parentPort
.
postMessage
(
backValue
);
}
break
;
default
:
break
;
}
}
\ No newline at end of file
compileruntime/worker_lib_standard/src/main/js/default/workers/worker_0121.js
0 → 100644
浏览文件 @
e773db36
/*
* Copyright (C) 2021 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import
worker
from
"
@ohos.worker
"
const
parentPort
=
worker
.
parentPort
;
var
ss
=
undefined
;
var
backValue
=
undefined
;
var
flag
=
false
;
parentPort
.
onmessage
=
function
(
e
)
{
var
data
=
e
.
data
;
switch
(
data
.
type
)
{
case
"
new
"
:
ss
=
new
worker
.
Worker
(
"
workers/worker_0122.js
"
);
parentPort
.
postMessage
(
ss
!=
null
)
break
;
default
:
break
;
}
}
\ No newline at end of file
compileruntime/worker_lib_standard/src/main/js/default/workers/worker_0122.js
0 → 100644
浏览文件 @
e773db36
/*
* Copyright (C) 2021 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import
worker
from
"
@ohos.worker
"
const
parentPort
=
worker
.
parentPort
;
var
ss
=
undefined
;
var
backValue
=
undefined
;
var
flag
=
false
;
parentPort
.
onmessage
=
function
(
e
)
{
console
.
log
(
"
worker:: thrid worker onmessage
"
)
}
\ No newline at end of file
compileruntime/worker_lib_standard/src/main/js/default/workers/worker_013.js
0 → 100644
浏览文件 @
e773db36
/*
* Copyright (C) 2021 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import
worker
from
"
@ohos.worker
"
const
parentPort
=
worker
.
parentPort
;
var
ss
=
undefined
;
var
backValue
=
undefined
;
var
flag
=
false
;
parentPort
.
onmessage
=
function
(
e
)
{
var
data
=
e
.
data
;
switch
(
data
.
type
)
{
case
"
new
"
:
ss
=
new
worker
.
Worker
(
"
workers/worker_0131.js
"
);
ss
.
onmessage
=
function
(
ee
)
{
backValue
=
ee
.
data
;
flag
=
true
;
}
ss
.
postMessage
(
data
.
value
);
break
;
case
"
wait
"
:
if
(
flag
)
{
parentPort
.
postMessage
(
backValue
);
}
break
;
default
:
break
;
}
}
\ No newline at end of file
compileruntime/worker_lib_standard/src/main/js/default/workers/worker_0131.js
0 → 100644
浏览文件 @
e773db36
/*
* Copyright (C) 2021 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import
worker
from
"
@ohos.worker
"
const
parentPort
=
worker
.
parentPort
;
parentPort
.
onmessage
=
function
(
e
)
{
var
data
=
e
.
data
;
// hello world
parentPort
.
postMessage
(
data
+
"
worker
"
);
// hello world worker
}
\ No newline at end of file
compileruntime/worker_lib_standard/src/main/js/default/workers/worker_014.js
0 → 100644
浏览文件 @
e773db36
/*
* Copyright (C) 2021 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import
worker
from
"
@ohos.worker
"
const
parentPort
=
worker
.
parentPort
;
var
ss
=
undefined
;
var
backValue
=
undefined
;
var
flag
=
false
;
parentPort
.
onmessage
=
function
(
e
)
{
var
data
=
e
.
data
;
switch
(
data
.
type
)
{
case
"
new
"
:
ss
=
new
worker
.
Worker
(
"
workers/worker_0141.js
"
);
ss
.
onmessage
=
function
(
ee
)
{
backValue
=
ee
.
data
;
flag
=
true
;
}
ss
.
postMessage
(
data
.
value
);
break
;
case
"
wait
"
:
if
(
flag
)
{
parentPort
.
postMessage
(
backValue
);
}
break
;
default
:
break
;
}
}
\ No newline at end of file
compileruntime/worker_lib_standard/src/main/js/default/workers/worker_0141.js
0 → 100644
浏览文件 @
e773db36
/*
* Copyright (C) 2021 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import
worker
from
"
@ohos.worker
"
const
parentPort
=
worker
.
parentPort
;
parentPort
.
onmessage
=
function
(
e
)
{
var
data
=
e
.
data
;
data
[
0
]
+=
1
parentPort
.
postMessage
(
data
);
// [2, 2]
}
\ No newline at end of file
compileruntime/worker_lib_standard/src/main/js/default/workers/worker_015.js
0 → 100644
浏览文件 @
e773db36
/*
* Copyright (C) 2021 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import
worker
from
"
@ohos.worker
"
const
parentPort
=
worker
.
parentPort
;
var
ss
=
undefined
;
var
backValue
=
undefined
;
var
flag
=
false
;
parentPort
.
onmessage
=
function
(
e
)
{
var
data
=
e
.
data
;
switch
(
data
.
type
)
{
case
"
new
"
:
ss
=
new
worker
.
Worker
(
"
workers/worker_0151.js
"
);
ss
.
onmessage
=
function
(
ee
)
{
backValue
=
ee
.
data
;
// 16
flag
=
true
;
}
ss
.
postMessage
({
type
:
"
new
"
,
value
:
data
.
value
+
1
});
// 11
break
;
case
"
wait
"
:
ss
.
postMessage
({
type
:
"
wait
"
});
if
(
flag
)
{
parentPort
.
postMessage
(
backValue
);
// 16
}
break
;
default
:
break
;
}
}
\ No newline at end of file
compileruntime/worker_lib_standard/src/main/js/default/workers/worker_0151.js
0 → 100644
浏览文件 @
e773db36
/*
* Copyright (C) 2021 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import
worker
from
"
@ohos.worker
"
const
parentPort
=
worker
.
parentPort
;
var
ss
=
undefined
;
var
backValue
=
undefined
;
var
flag
=
false
;
parentPort
.
onmessage
=
function
(
e
)
{
var
data
=
e
.
data
;
switch
(
data
.
type
)
{
case
"
new
"
:
ss
=
new
worker
.
Worker
(
"
workers/worker_0152.js
"
);
ss
.
onmessage
=
function
(
ee
)
{
backValue
=
ee
.
data
;
flag
=
true
;
}
ss
.
postMessage
(
data
.
value
+
2
);
// 13
break
;
case
"
wait
"
:
if
(
flag
)
{
parentPort
.
postMessage
(
backValue
);
// 16
}
break
;
default
:
break
;
}
}
\ No newline at end of file
compileruntime/worker_lib_standard/src/main/js/default/workers/worker_0152.js
0 → 100644
浏览文件 @
e773db36
/*
* Copyright (C) 2021 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import
worker
from
"
@ohos.worker
"
const
parentPort
=
worker
.
parentPort
;
parentPort
.
onmessage
=
function
(
e
)
{
var
data
=
e
.
data
;
parentPort
.
postMessage
(
data
+
3
);
// 16
}
\ No newline at end of file
compileruntime/worker_lib_standard/src/main/js/test/List.test.js
浏览文件 @
e773db36
...
...
@@ -13,5 +13,4 @@
* limitations under the License.
*/
require
(
'
./ExampleJsunit.test.js
'
)
require
(
"
./Worker.test.js
"
)
\ No newline at end of file
compileruntime/worker_lib_standard/src/main/js/test/Worker.test.js
浏览文件 @
e773db36
/*
* Copyright (C) 2021 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the
"License");
* Licensed under the Apache License, Version 2.0 (the
'License')
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an
"AS IS" BASIS,
* distributed under the License is distributed on an
'AS IS' BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
...
...
@@ -16,8 +16,7 @@
// @ts-nocheck
import
app
from
'
@system.app
'
import
{
describe
,
beforeAll
,
beforeEach
,
afterEach
,
afterAll
,
it
,
expect
}
from
'
deccjsunit/index
'
//import worker from "@ohos.worker";
var
worker
=
globalThis
.
requireNapi
(
'
worker
'
);
import
worker
from
"
@ohos.worker
"
;
describe
(
'
workerTest
'
,
function
()
{
...
...
@@ -146,7 +145,22 @@ describe('workerTest', function () {
const
buffer
=
new
ArrayBuffer
(
8
)
expect
(
buffer
.
byteLength
).
assertEqual
(
8
)
ss
.
postMessage
(
buffer
,
[
buffer
])
expect
(
buffer
.
byteLength
).
assertEqual
(
0
)
var
length
=
undefined
;
var
exception
=
undefined
;
try
{
length
=
buffer
.
byteLength
;
}
catch
(
e
)
{
exception
=
e
.
message
;
}
console
.
log
(
"
worker:: length is
"
+
length
)
console
.
log
(
"
worker:: exception is
"
+
exception
)
if
(
typeof
exception
==
"
undefined
"
)
{
expect
(
length
).
assertEqual
(
0
)
}
else
{
expect
(
exception
).
assertEqual
(
"
IsDetachedBuffer
"
)
}
})
// check worker handle error is ok
...
...
@@ -464,6 +478,7 @@ describe('workerTest', function () {
ss
.
dispatchEvent
({
type
:
"
zhangsan
"
})
expect
(
zhangsan_times
).
assertEqual
(
2
)
})
// check worker removeAllListener function is ok
...
...
@@ -502,65 +517,23 @@ describe('workerTest', function () {
it
(
'
worker_parentPortClose_test_001
'
,
0
,
async
function
(
done
)
{
var
ss
=
new
worker
.
Worker
(
"
workers/worker_008.js
"
);
var
res
=
0
var
flag
=
false
;
ss
.
on
message
=
function
(
e
)
{
ss
.
on
exit
=
function
(
e
)
{
res
++
;
flag
=
true
;
}
ss
.
postMessage
(
"
abc
"
)
while
(
!
flag
)
{
await
promiseCase
()
expect
(
res
).
assertEqual
(
0
)
done
()
})
// check parentPort.close is ok
it
(
'
worker_parentPortClose_test_002
'
,
0
,
async
function
(
done
)
{
var
ss1
=
new
worker
.
Worker
(
"
workers/worker_008.js
"
);
var
ss2
=
new
worker
.
Worker
(
"
workers/worker_008.js
"
);
var
res
=
0
var
times
=
0
ss1
.
onmessage
=
function
(
e
)
{
res
++
;
}
ss1
.
postMessage
(
"
abc
"
)
await
promiseCase
()
expect
(
res
).
assertEqual
(
0
)
ss2
.
postMessage
(
"
hello world
"
)
await
promiseCase
()
expect
(
res
).
assertEqual
(
0
)
done
()
})
// check parentPort.close is ok
it
(
'
worker_parentPortClose_test_003
'
,
0
,
async
function
(
done
)
{
var
ss1
=
new
worker
.
Worker
(
"
workers/worker_008.js
"
);
var
ss2
=
new
worker
.
Worker
(
"
workers/worker_008.js
"
);
var
res
=
0
var
times
=
0
ss1
.
onmessage
=
function
(
e
)
{
res
++
;
}
ss1
.
postMessage
(
"
abc
"
)
await
promiseCase
()
expect
(
res
).
assertEqual
(
0
)
ss2
.
addEventListener
(
"
zhangsan
"
,
()
=>
{
times
++
;
})
ss2
.
dispatchEvent
({
type
:
"
zhangsan
"
})
expect
(
times
).
assertEqual
(
1
)
expect
(
res
).
assertEqual
(
1
)
done
()
})
// check parentPort.close is ok
it
(
'
worker_parentPortClose_test_00
4
'
,
0
,
async
function
(
done
)
{
it
(
'
worker_parentPortClose_test_00
2
'
,
0
,
async
function
(
done
)
{
var
ss
=
new
worker
.
Worker
(
"
workers/worker_008.js
"
);
var
res
=
0
var
flag
=
false
;
...
...
@@ -625,4 +598,183 @@ describe('workerTest', function () {
expect
(
res
).
assertEqual
(
1
)
done
()
})
// check new second worker is ok
it
(
'
worker_new_second_worker_test_001
'
,
0
,
async
function
(
done
)
{
var
ss
=
new
worker
.
Worker
(
"
workers/worker_009.js
"
);
var
flag
=
false
;
var
res
=
undefined
;
ss
.
onmessage
=
function
(
e
)
{
flag
=
true
;
res
=
e
.
data
;
}
ss
.
postMessage
({
type
:
"
new
"
,
value
:
12
})
while
(
!
flag
)
{
console
.
log
(
"
worker:: foo wait
"
)
await
promiseCase
();
}
console
.
log
(
"
worker::
"
+
res
)
expect
(
res
).
assertTrue
();
done
();
})
// check new third worker is ok
it
(
'
worker_new_second_worker_test_002
'
,
0
,
async
function
(
done
)
{
var
ss
=
new
worker
.
Worker
(
"
workers/worker_012.js
"
);
var
flag
=
false
;
var
res
=
undefined
;
ss
.
onmessage
=
function
(
e
)
{
flag
=
true
;
res
=
e
.
data
;
}
ss
.
onerror
=
function
(
ee
)
{
console
.
log
(
"
worker::
"
+
ee
.
message
)
}
ss
.
postMessage
({
type
:
"
new
"
,
value
:
12
});
while
(
!
flag
)
{
console
.
log
(
"
worker:: worker_second_worker_postMessage_test_001 wait
"
);
ss
.
postMessage
({
type
:
"
wait
"
});
await
promiseCase
();
}
expect
(
res
).
assertTrue
();
done
();
})
// check second worker postMessage number is ok
it
(
'
worker_second_worker_postMessage_test_001
'
,
0
,
async
function
(
done
)
{
var
ss
=
new
worker
.
Worker
(
"
workers/worker_010.js
"
);
var
flag
=
false
;
var
res
=
undefined
;
ss
.
onmessage
=
function
(
e
)
{
flag
=
true
;
res
=
e
.
data
;
}
ss
.
onerror
=
function
(
ee
)
{
console
.
log
(
"
worker::
"
+
ee
.
message
)
}
ss
.
postMessage
({
type
:
"
new
"
,
value
:
12
});
while
(
!
flag
)
{
console
.
log
(
"
worker:: worker_second_worker_postMessage_test_001 wait
"
);
ss
.
postMessage
({
type
:
"
wait
"
});
await
promiseCase
();
}
expect
(
res
).
assertEqual
(
25
);
done
();
})
// check second worker postMessage string is ok
it
(
'
worker_second_worker_postMessage_test_002
'
,
0
,
async
function
(
done
)
{
var
ss
=
new
worker
.
Worker
(
"
workers/worker_013.js
"
);
var
flag
=
false
;
var
res
=
undefined
;
ss
.
onmessage
=
function
(
e
)
{
flag
=
true
;
res
=
e
.
data
;
}
ss
.
onerror
=
function
(
ee
)
{
console
.
log
(
"
worker::
"
+
ee
.
message
)
}
ss
.
postMessage
({
type
:
"
new
"
,
value
:
"
hello world
"
});
while
(
!
flag
)
{
console
.
log
(
"
worker:: worker_second_worker_postMessage_test_002 wait
"
)
ss
.
postMessage
({
type
:
"
wait
"
});
await
promiseCase
();
}
expect
(
res
).
assertEqual
(
"
hello world worker
"
);
done
();
})
// check second worker postMessage array is ok
it
(
'
worker_second_worker_postMessage_test_003
'
,
0
,
async
function
(
done
)
{
var
ss
=
new
worker
.
Worker
(
"
workers/worker_014.js
"
);
var
flag
=
false
;
var
res
=
undefined
;
ss
.
onmessage
=
function
(
e
)
{
flag
=
true
;
res
=
e
.
data
;
}
ss
.
onerror
=
function
(
ee
)
{
console
.
log
(
"
worker::
"
+
ee
.
message
)
}
ss
.
postMessage
({
type
:
"
new
"
,
value
:
[
1
,
2
]});
while
(
!
flag
)
{
console
.
log
(
"
worker:: worker_second_worker_postMessage_test_003 wait
"
)
ss
.
postMessage
({
type
:
"
wait
"
});
await
promiseCase
();
}
expect
(
res
[
0
]).
assertEqual
(
2
);
expect
(
res
[
1
]).
assertEqual
(
2
);
done
();
})
// check third worker postMessage is ok
it
(
'
worker_second_worker_postMessage_test_004
'
,
0
,
async
function
(
done
)
{
var
ss
=
new
worker
.
Worker
(
"
workers/worker_015.js
"
);
var
flag
=
false
;
var
res
=
undefined
;
ss
.
onmessage
=
function
(
e
)
{
flag
=
true
;
res
=
e
.
data
;
}
ss
.
onerror
=
function
(
ee
)
{
console
.
log
(
"
worker::
"
+
ee
.
message
)
}
ss
.
postMessage
({
type
:
"
new
"
,
value
:
10
});
while
(
!
flag
)
{
console
.
log
(
"
worker:: worker_second_worker_postMessage_test_003 wait
"
)
ss
.
postMessage
({
type
:
"
wait
"
});
await
promiseCase
();
}
expect
(
res
).
assertEqual
(
16
);
done
();
})
// check second worker terminate is ok
it
(
'
worker_second_worker_terminate_test_001
'
,
0
,
async
function
(
done
)
{
var
ss
=
new
worker
.
Worker
(
"
workers/worker_011.js
"
);
var
flag
=
false
;
var
res
=
undefined
;
ss
.
onmessage
=
function
(
e
)
{
flag
=
true
;
res
=
e
.
data
;
}
ss
.
onerror
=
function
(
ee
)
{
console
.
log
(
"
worker::
"
+
ee
.
message
)
}
ss
.
postMessage
({
type
:
"
new
"
,
value
:
12
});
while
(
!
flag
)
{
ss
.
postMessage
({
type
:
"
wait
"
});
await
promiseCase
();
}
flag
=
false
;
ss
.
postMessage
({
type
:
"
terminate
"
});
while
(
!
flag
)
{
ss
.
postMessage
({
type
:
"
wait
"
});
await
promiseCase
();
}
expect
(
res
).
assertEqual
(
"
terminate
"
);
done
();
})
})
\ No newline at end of file
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录