Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
.Veneno.
wechaty
提交
97682d3d
W
wechaty
项目概览
.Veneno.
/
wechaty
与 Fork 源项目一致
Fork自
wechaty / wechaty
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
W
wechaty
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
97682d3d
编写于
7月 05, 2016
作者:
Huan (李卓桓)
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
code clean
上级
3fcc1a68
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
35 addition
and
30 deletion
+35
-30
src/puppet-web-browser.js
src/puppet-web-browser.js
+25
-22
src/puppet-web-event.js
src/puppet-web-event.js
+4
-3
src/puppet-web.js
src/puppet-web.js
+6
-5
未找到文件。
src/puppet-web-browser.js
浏览文件 @
97682d3d
...
...
@@ -141,26 +141,28 @@ class Browser extends EventEmitter {
return
Promise
.
resolve
(
'
no driver session
'
)
}
return
this
.
driver
.
close
()
// http://stackoverflow.com/a/32341885/1123955
.
then
(()
=>
this
.
driver
.
quit
())
.
catch
(
e
=>
{
// console.log(e)
// log.warn('PuppetWebBrowser', 'err: %s %s %s %s', e.code, e.errno, e.syscall, e.message)
const
crashMsgs
=
[
'
ECONNREFUSED
'
,
'
WebDriverError: .* not reachable
'
,
'
NoSuchWindowError: no such window: target window already closed
'
]
const
crashRegex
=
new
RegExp
(
crashMsgs
.
join
(
'
|
'
),
'
i
'
)
if
(
crashRegex
.
test
(
e
.
message
))
{
log
.
warn
(
'
PuppetWebBrowser
'
,
'
driver.quit() browser crashed
'
)
}
else
{
log
.
warn
(
'
PuppetWebBrowser
'
,
'
driver.quit() exception: %s
'
,
e
.
message
)
}
})
.
then
(()
=>
{
this
.
driver
=
null
})
.
then
(()
=>
this
.
clean
())
.
catch
(
e
=>
{
log
.
error
(
'
PuppetWebBrowser
'
,
'
quit() exception: %s
'
,
e
.
message
)
throw
e
})
.
then
(
_
=>
this
.
driver
.
quit
())
.
catch
(
e
=>
{
// console.log(e)
// log.warn('PuppetWebBrowser', 'err: %s %s %s %s', e.code, e.errno, e.syscall, e.message)
const
crashMsgs
=
[
'
ECONNREFUSED
'
,
'
WebDriverError: .* not reachable
'
,
'
NoSuchWindowError: no such window: target window already closed
'
]
const
crashRegex
=
new
RegExp
(
crashMsgs
.
join
(
'
|
'
),
'
i
'
)
if
(
crashRegex
.
test
(
e
.
message
))
{
log
.
warn
(
'
PuppetWebBrowser
'
,
'
driver.quit() browser crashed
'
)
}
else
{
log
.
warn
(
'
PuppetWebBrowser
'
,
'
driver.quit() exception: %s
'
,
e
.
message
)
}
})
.
then
(
_
=>
{
this
.
driver
=
null
return
this
.
clean
()
})
.
catch
(
e
=>
{
log
.
error
(
'
PuppetWebBrowser
'
,
'
quit() exception: %s
'
,
e
.
message
)
throw
e
})
}
clean
()
{
...
...
@@ -182,6 +184,7 @@ class Browser extends EventEmitter {
this
.
getBrowserPids
()
.
then
(
pids
=>
{
if
(
pids
.
length
===
0
)
{
log
.
verbose
(
'
PuppetWebBrowser
'
,
'
clean() retryPromise() resolved
'
)
resolve
(
'
clean() no browser process, confirm clean
'
)
}
else
{
reject
(
new
Error
(
'
clean() found browser process, not clean, dirty
'
))
...
...
@@ -327,8 +330,8 @@ class Browser extends EventEmitter {
log
.
warn
(
'
PuppetWebBrowser
'
,
'
dead() because %s
'
,
errMsg
)
this
.
live
=
false
// must use nextTick here, or promise will hang... 2016/6/10
process
.
nextTick
(
()
=>
{
log
.
verbose
(
'
PuppetWebBrowser
'
,
'
dead() emit a `dead` event
'
)
process
.
nextTick
(
_
=>
{
log
.
verbose
(
'
PuppetWebBrowser
'
,
'
dead() emit a `dead` event
because %s
'
,
errMsg
)
this
.
emit
(
'
dead
'
,
errMsg
)
})
}
...
...
src/puppet-web-event.js
浏览文件 @
97682d3d
...
...
@@ -51,7 +51,7 @@ const PuppetWebEvent = {
}
function
onBrowserDead
(
e
)
{
log
.
verbose
(
'
PuppetWebEvent
'
,
'
onBrowserDead(
)
'
)
log
.
verbose
(
'
PuppetWebEvent
'
,
'
onBrowserDead(
%s)
'
,
e
)
// because this function is async, so maybe entry more than one times.
// guard by variable: isBrowserBirthing to prevent the 2nd time entrance.
if
(
this
.
isBrowserBirthing
)
{
...
...
@@ -84,10 +84,11 @@ function onBrowserDead(e) {
})
log
.
verbose
(
'
PuppetWebEvent
'
,
'
old browser quited
'
)
yield
this
.
initBrowser
()
this
.
browser
=
yield
this
.
initBrowser
()
log
.
verbose
(
'
PuppetWebEvent
'
,
'
new browser inited
'
)
yield
this
.
bridge
.
init
()
// this.bridge = yield this.bridge.init()
this
.
bridge
=
yield
this
.
initBridge
()
log
.
verbose
(
'
PuppetWebEvent
'
,
'
bridge re-inited
'
)
const
dong
=
yield
this
.
ding
()
...
...
src/puppet-web.js
浏览文件 @
97682d3d
...
...
@@ -88,7 +88,7 @@ class PuppetWeb extends Puppet {
if
(
this
.
bridge
)
{
yield
this
.
bridge
.
quit
().
catch
(
e
=>
{
// fail safe
log
.
warn
(
'
PuppetWeb
'
,
'
quit
e
() bridge.quit() exception: %s
'
,
e
.
message
)
log
.
warn
(
'
PuppetWeb
'
,
'
quit() bridge.quit() exception: %s
'
,
e
.
message
)
})
this
.
bridge
=
null
}
else
{
log
.
warn
(
'
PuppetWeb
'
,
'
quit() without a bridge
'
)
}
...
...
@@ -99,9 +99,10 @@ class PuppetWeb extends Puppet {
}
else
{
log
.
verbose
(
'
PuppetWeb
'
,
'
quit() without a server
'
)
}
if
(
this
.
browser
)
{
yield
(
this
.
browser
.
quit
().
catch
(
e
=>
{
// fail safe
log
.
warn
(
'
PuppetWeb
'
,
'
quit() browser.quit() exception: %s
'
,
e
.
message
)
}))
yield
this
.
browser
.
quit
()
.
catch
(
e
=>
{
// fail safe
log
.
warn
(
'
PuppetWeb
'
,
'
quit() browser.quit() exception: %s
'
,
e
.
message
)
})
this
.
browser
=
null
}
else
{
log
.
warn
(
'
PuppetWeb
'
,
'
quit() without a browser
'
)
}
...
...
@@ -127,7 +128,7 @@ class PuppetWeb extends Puppet {
initBrowser
()
{
log
.
verbose
(
'
PuppetWeb
'
,
'
initBrowser()
'
)
const
browser
=
this
.
browser
=
new
Browser
({
const
browser
=
new
Browser
({
head
:
this
.
head
,
sessionFile
:
this
.
profile
})
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录