Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
G
Geth-Modification
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
张蕾
Geth-Modification
Commits
f27e826b
Commit
f27e826b
authored
Nov 23, 2015
by
Péter Szilágyi
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
jrse: fix #1082, fail if setTimeout/setInterval lack callback
parent
ae9e9efa
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
15 additions
and
5 deletions
+15
-5
jsre.go
jsre/jsre.go
+15
-5
No files found.
jsre/jsre.go
View file @
f27e826b
...
...
@@ -85,7 +85,6 @@ func (self *JSRE) runEventLoop() {
ready
:=
make
(
chan
*
jsTimer
)
newTimer
:=
func
(
call
otto
.
FunctionCall
,
interval
bool
)
(
*
jsTimer
,
otto
.
Value
)
{
delay
,
_
:=
call
.
Argument
(
1
)
.
ToInteger
()
if
0
>=
delay
{
delay
=
1
...
...
@@ -105,7 +104,6 @@ func (self *JSRE) runEventLoop() {
if
err
!=
nil
{
panic
(
err
)
}
return
timer
,
value
}
...
...
@@ -127,8 +125,20 @@ func (self *JSRE) runEventLoop() {
}
return
otto
.
UndefinedValue
()
}
vm
.
Set
(
"setTimeout"
,
setTimeout
)
vm
.
Set
(
"setInterval"
,
setInterval
)
vm
.
Set
(
"_setTimeout"
,
setTimeout
)
vm
.
Set
(
"_setInterval"
,
setInterval
)
vm
.
Run
(
`var setTimeout = function(args) {
if (arguments.length < 1) {
throw TypeError("Failed to execute 'setTimeout': 1 argument required, but only 0 present.");
}
return _setTimeout.apply(this, arguments);
}`
)
vm
.
Run
(
`var setInterval = function(args) {
if (arguments.length < 1) {
throw TypeError("Failed to execute 'setInterval': 1 argument required, but only 0 present.");
}
return _setInterval.apply(this, arguments);
}`
)
vm
.
Set
(
"clearTimeout"
,
clearTimeout
)
vm
.
Set
(
"clearInterval"
,
clearTimeout
)
...
...
@@ -154,7 +164,7 @@ loop:
if
err
!=
nil
{
fmt
.
Println
(
"js error:"
,
err
,
arguments
)
}
_
,
inreg
:=
registry
[
timer
]
// when clearInterval is called from within the callback don't reset it
if
timer
.
interval
&&
inreg
{
timer
.
timer
.
Reset
(
timer
.
duration
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment