未验证 提交 e773db36 编写于 作者: O openharmony_ci 提交者: Gitee

!1495 add second worker xts testcase

Merge pull request !1495 from yaojian16/master
......@@ -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",
]
}
}
......@@ -5,6 +5,10 @@
"version": {
"code": 1000000,
"name": "1.0.0"
},
"apiVersion": {
"compatible": 4,
"target": 5
}
},
"deviceConfig": {},
......
/*
* 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.
*/
/******/ (() => { // webpackBootstrap
var __webpack_exports__ = {};
/*!********************************************************************************************!*\
!*** d:\workspace\my_works\MyApplication\entry\src\main\ets\default\workers\WorkerDemo.js ***!
\********************************************************************************************/
function foo(x) {return x}
var worker = globalThis.requireNapi('worker');
const parentPort = worker.parentPort;
console.info("worker:: new version")
parentPort.onclose = function() {
console.info("worker::worker.js onclose");
}
parentPort.onmessage = function(e) {
var data = e.data;
console.info("worker:: worker thread worker data is " + data.data);
switch(data.type) {
case "normal":
console.info("worker:: worker thread receive data " + data.data);
parentPort.postMessage(data);
console.info("worker:: worker thread post back");
break;
case "error":
throw new Error("123");
break;
case "buffer":
console.info("worker:: worker.js receive buffer length is " + data.data.byteLength);
parentPort.postMessage(data, [data.data]);
console.info("worker:: worker.js post buffer length is " + data.data.byteLength);
break;
default:
console.info("worker:: worker.js receive unknow type");
break
}
}
// 反序列错误
parentPort.onmessageerror = function() {
console.info("worker:: worker.js onmessageerror");
}
// 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
/*
* 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;
console.info("worker:: new version")
parentPort.onclose = function() {
console.info("worker::worker.js onclose");
}
parentPort.onmessage = function(e) {
var data = e.data;
console.info("worker:: worker thread worker data is " + data.data);
switch(data.type) {
case "normal":
console.info("worker:: worker thread receive data " + data.data);
parentPort.postMessage(data);
console.info("worker:: worker thread post back");
break;
case "error":
throw new Error("123");
break;
case "buffer":
console.info("worker:: worker.js receive buffer length is " + data.data.byteLength);
parentPort.postMessage(data, [data.data]);
console.info("worker:: worker.js post buffer length is " + data.data.byteLength);
break;
default:
console.info("worker:: worker.js receive unknow type");
break
}
}
// 反序列错误
parentPort.onmessageerror = function() {
console.info("worker:: worker.js onmessageerror");
}
// 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
/*
* 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.
*/
/******/ (() => { // 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');
const parentPort = worker.parentPort;
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
/*
* 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:: worker receive data " + e.data);
var data = e.data + " worker";
parentPort.postMessage(data)
}
\ No newline at end of file
/*
* 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.
*/
/******/ (() => { // webpackBootstrap
var __webpack_exports__ = {};
/*!********************************************************************************************!*\
!*** d:\workspace\my_works\MyApplication\entry\src\main\ets\default\workers\WorkerDemo.js ***!
\********************************************************************************************/
var worker = globalThis.requireNapi('worker');
const parentPort = worker.parentPort;
parentPort.onmessage = function(e) {
var data = e.data * 2 + 1
parentPort.postMessage(data)
}
/******/ })()
;
\ No newline at end of file
/*
* 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 * 2 + 1
parentPort.postMessage(data)
}
\ No newline at end of file
/*
* 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.
*/
/******/ (() => { // webpackBootstrap
var __webpack_exports__ = {};
/*!********************************************************************************************!*\
!*** d:\workspace\my_works\MyApplication\entry\src\main\ets\default\workers\WorkerDemo.js ***!
\********************************************************************************************/
var worker = globalThis.requireNapi('worker');
const parentPort = worker.parentPort;
parentPort.onmessage = function(e) {
var data = e.data;
data.message = "hello world " + "worker"
parentPort.postMessage(data)
}
/******/ })()
;
\ No newline at end of file
/*
* 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.message = "hello world " + "worker"
parentPort.postMessage(data)
}
\ No newline at end of file
/*
* 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.
*/
/******/ (() => { // webpackBootstrap
var __webpack_exports__ = {};
/*!********************************************************************************************!*\
!*** d:\workspace\my_works\MyApplication\entry\src\main\ets\default\workers\WorkerDemo.js ***!
\********************************************************************************************/
var worker = globalThis.requireNapi('worker');
const parentPort = worker.parentPort;
parentPort.onmessage = function(e) {
parentPort.postMessage(name)
}
/******/ })()
;
\ No newline at end of file
/*
* 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) {
parentPort.postMessage(name)
}
\ No newline at end of file
/*
* 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.
*/
/******/ (() => { // webpackBootstrap
var __webpack_exports__ = {};
/*!********************************************************************************************!*\
!*** d:\workspace\my_works\MyApplication\entry\src\main\ets\default\workers\WorkerDemo.js ***!
\********************************************************************************************/
var worker = globalThis.requireNapi('worker');
const parentPort = worker.parentPort;
parentPort.onmessage = function(e) {
parentPort.postMessage("hello world")
}
/******/ })()
;
\ No newline at end of file
/*
* 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) {
parentPort.postMessage("hello world")
}
\ No newline at end of file
/*
* 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.
*/
/******/ (() => { // webpackBootstrap
var __webpack_exports__ = {};
/*!********************************************************************************************!*\
!*** d:\workspace\my_works\MyApplication\entry\src\main\ets\default\workers\WorkerDemo.js ***!
\********************************************************************************************/
var worker = globalThis.requireNapi('worker');
const parentPort = worker.parentPort;
parentPort.onmessage = function(e) {
throw new Error(123)
}
/******/ })()
;
\ No newline at end of file
/*
* 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) {
throw new Error(123)
}
\ No newline at end of file
/*
* 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.
*/
/******/ (() => { // webpackBootstrap
var __webpack_exports__ = {};
/*!********************************************************************************************!*\
!*** d:\workspace\my_works\MyApplication\entry\src\main\ets\default\workers\WorkerDemo.js ***!
\********************************************************************************************/
var worker = globalThis.requireNapi('worker');
const parentPort = worker.parentPort;
parentPort.onmessage = function(e) {
parentPort.close()
}
/******/ })()
;
\ No newline at end of file
/*
* 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) {
parentPort.close()
}
/*
* 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
......@@ -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
/*
* 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
/*
* 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
/*
* 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
/*
* 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
/*
* 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
/*
* 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
/*
* 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
/*
* 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
/*
* 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
/*
* 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
/*
* 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
/*
* 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
/*
* 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
/*
* 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
/*
* 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.
*/
require('./ExampleJsunit.test.js')
/*
* 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.
*/
require("./Worker.test.js")
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册