Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
dotNET Platform
runtime
提交
8be118e5
R
runtime
项目概览
dotNET Platform
/
runtime
12 个月 前同步成功
通知
1
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
R
runtime
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
未验证
提交
8be118e5
编写于
2月 25, 2021
作者:
L
Larry Ewing
提交者:
GitHub
2月 25, 2021
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Clean up the console redirect a little (#48206)
上级
1f866d2c
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
50 addition
and
43 deletion
+50
-43
src/mono/wasm/runtime-test.js
src/mono/wasm/runtime-test.js
+50
-43
未找到文件。
src/mono/wasm/runtime-test.js
浏览文件 @
8be118e5
...
...
@@ -5,63 +5,70 @@
//glue code to deal with the differences between chrome, ch, d8, jsc and sm.
var
is_browser
=
typeof
window
!=
"
undefined
"
;
var
consoleWebSocket
;
var
print
;
if
(
is_browser
)
{
// We expect to be run by tests/runtime/run.js which passes in the arguments using http parameters
window
.
real_print
=
console
.
log
;
print
=
function
(
_msg
)
{
window
.
real_print
(
_msg
);
};
console
.
log
=
print
;
console
.
debug
=
print
;
console
.
error
=
print
;
console
.
trace
=
print
;
console
.
warn
=
print
;
console
.
info
=
print
;
// if the engine doesn't provide a console
if
(
typeof
(
console
)
===
"
undefined
"
)
{
var
console
=
{
log
:
globalThis
.
print
,
clear
:
function
()
{
}
};
}
globalThis
.
testConsole
=
console
;
function
proxyMethod
(
prefix
,
func
,
asJson
)
{
return
function
()
{
var
args
=
[...
arguments
];
if
(
asJson
)
{
func
(
JSON
.
stringify
({
method
:
prefix
,
payload
:
args
[
0
],
arguments
:
args
}));
}
else
{
func
([
prefix
+
args
[
0
],
...
args
.
slice
(
1
)]);
}
};
};
var
methods
=
[
"
debug
"
,
"
trace
"
,
"
warn
"
,
"
info
"
,
"
error
"
];
for
(
var
m
of
methods
)
{
if
(
typeof
(
console
[
m
])
!=
"
function
"
)
{
console
[
m
]
=
proxyMethod
(
`console.
${
m
}
: `
,
console
.
log
,
false
);
}
}
function
proxyJson
(
func
)
{
for
(
var
m
of
[
"
log
"
,
...
methods
])
console
[
m
]
=
proxyMethod
(
`console.
${
m
}
`
,
func
,
true
);
}
if
(
is_browser
)
{
const
consoleUrl
=
`
${
window
.
location
.
origin
}
/console`
.
replace
(
'
http://
'
,
'
ws://
'
);
consoleWebSocket
=
new
WebSocket
(
consoleUrl
);
let
consoleWebSocket
=
new
WebSocket
(
consoleUrl
);
consoleWebSocket
.
onopen
=
function
(
event
)
{
consoleWebSocket
.
send
(
"
browser: Console websocket connected.
"
);
window
.
real_print
=
function
(
msg
)
{
consoleWebSocket
.
send
(
msg
);
};
proxyJson
(
function
(
msg
)
{
consoleWebSocket
.
send
(
msg
);
});
globalThis
.
testConsole
.
log
(
"
browser: Console websocket connected.
"
);
};
consoleWebSocket
.
onerror
=
function
(
event
)
{
console
.
log
(
`websocket error:
${
event
}
`
);
};
// We expect to be run by tests/runtime/run.js which passes in the arguments using http parameters
var
url
=
new
URL
(
decodeURI
(
window
.
location
));
arguments
=
[];
for
(
var
v
of
url
.
searchParams
)
{
if
(
v
[
0
]
==
"
arg
"
)
{
console
.
log
(
"
URL ARG:
"
+
v
[
0
]
+
"
=
"
+
v
[
1
]);
arguments
.
push
(
v
[
1
]);
}
}
}
//proxyJson(console.log);
// JavaScript core does not have a console defined
if
(
typeof
console
===
"
undefined
"
)
{
var
Console
=
function
()
{
this
.
log
=
function
(
msg
){
print
(
msg
)
};
this
.
clear
=
function
()
{
};
};
console
=
new
Console
();
}
if
(
typeof
console
!==
"
undefined
"
)
{
if
(
!
console
.
debug
)
console
.
debug
=
console
.
log
;
if
(
!
console
.
trace
)
console
.
trace
=
console
.
log
;
if
(
!
console
.
warn
)
console
.
warn
=
console
.
log
;
if
(
!
console
.
error
)
console
.
error
=
console
.
log
;
}
let
print
=
globalThis
.
testConsole
.
log
;
let
printErr
=
globalThis
.
testConsole
.
error
;
if
(
typeof
crypto
===
'
undefined
'
)
{
// **NOTE** this is a simple insecure polyfill for testing purposes only
...
...
@@ -112,7 +119,7 @@ function test_exit (exit_code) {
if
(
is_browser
)
{
// Notify the selenium script
Module
.
exit_code
=
exit_code
;
print
(
"
WASM EXIT
"
+
exit_code
);
Module
.
print
(
"
WASM EXIT
"
+
exit_code
);
var
tests_done_elem
=
document
.
createElement
(
"
label
"
);
tests_done_elem
.
id
=
"
tests_done
"
;
tests_done_elem
.
innerHTML
=
exit_code
.
toString
();
...
...
@@ -123,7 +130,7 @@ function test_exit (exit_code) {
}
function
fail_exec
(
reason
)
{
print
(
reason
);
Module
.
print
(
reason
);
test_exit
(
1
);
}
...
...
@@ -138,7 +145,7 @@ function inspect_object (o) {
// Preprocess arguments
var
args
=
testArguments
;
print
(
"
Arguments:
"
+
testArguments
);
console
.
info
(
"
Arguments:
"
+
testArguments
);
profilers
=
[];
setenv
=
{};
runtime_args
=
[];
...
...
@@ -202,8 +209,8 @@ loadScript ("mono-config.js");
var
Module
=
{
mainScriptUrlOrBlob
:
"
dotnet.js
"
,
print
:
print
,
printErr
:
function
(
x
)
{
print
(
"
WASM-ERR:
"
+
x
)
}
,
print
,
printErr
,
onAbort
:
function
(
x
)
{
print
(
"
ABORT:
"
+
x
);
...
...
@@ -297,7 +304,7 @@ var App = {
Module
.
wasm_exit
=
Module
.
cwrap
(
'
mono_wasm_exit
'
,
'
void
'
,
[
'
number
'
]);
Module
.
print
(
"
Initializing.....
"
);
console
.
info
(
"
Initializing.....
"
);
for
(
var
i
=
0
;
i
<
profilers
.
length
;
++
i
)
{
var
init
=
Module
.
cwrap
(
'
mono_wasm_load_profiler_
'
+
profilers
[
i
],
'
void
'
,
[
'
string
'
])
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录