This repository has been archived by the owner on Jan 30, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 43
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This will help ensure that the DblClick behaviour matches the two separate behaviours.
- Loading branch information
Showing
2 changed files
with
51 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
package tests | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/stretchr/testify/assert" | ||
"github.com/stretchr/testify/require" | ||
) | ||
|
||
func TestMouseDblClick(t *testing.T) { | ||
t.Parallel() | ||
|
||
b := newTestBrowser(t, withFileServer()) | ||
p := b.NewPage(nil) | ||
_, err := p.Goto(b.staticURL("dbl_click.html"), nil) | ||
require.NoError(t, err) | ||
|
||
p.Mouse.DblClick(35, 17, nil) | ||
|
||
v := p.Evaluate(b.toGojaValue(`() => window.dblclick`)) | ||
assert.True(t, b.asGojaBool(v), "failed to double click the link") | ||
|
||
got := p.InnerText("#counter", nil) | ||
assert.Equal(t, "2", got) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
|
||
<head> | ||
<title>Clickable link test</title> | ||
</head> | ||
|
||
<body> | ||
<a id="linkdbl" href="#" ondblclick="event.preventDefault()" onclick="incrementCounter()">Dblclick</a> | ||
Counter: <span id="counter">0</span> | ||
|
||
<script> | ||
window.dblclick = false; | ||
|
||
document.querySelector('#linkdbl').addEventListener( | ||
'dblclick', e => { window.dblclick = true }, false | ||
); | ||
|
||
var counter = 0; | ||
function incrementCounter() { | ||
document.getElementById("counter").textContent = ++counter; | ||
} | ||
</script> | ||
</body> | ||
|
||
</html> |