Add tests for manual selection

This commit is contained in:
Jay Kamat 2017-05-09 00:11:25 -07:00
parent d1aac9e9e9
commit 02f79c2990
No known key found for this signature in database
GPG Key ID: 5D2E399600F4F7B5
3 changed files with 28 additions and 1 deletions

View File

@ -16,7 +16,7 @@
BAZ<br/>
space travel<br/>
/slash<br/>
<a href="hello.txt">follow me!</a><br/>
<a class="toselect" href="hello.txt">follow me!</a><br/>
</p>
</body>
</html>

View File

@ -0,0 +1,13 @@
/* Select all elements marked with toselect */
var toSelect = document.getElementsByClassName("toselect");
var s = window.getSelection();
if(s.rangeCount > 0) s.removeAllRanges();
for(var i = 0; i < toSelect.length; i++) {
var range = document.createRange();
range.selectNode(toSelect[i]);
s.addRange(range);
}

View File

@ -224,3 +224,17 @@ Feature: Searching on a page
And I run :follow-selected -t
Then the following tabs should be open:
- data/search.html (active)
Scenario: Follow a manually selected link
When I run :jseval --file (testdata)/search_select.js
And I run :follow-selected
Then data/hello.txt should be loaded
Scenario: Follow a manually selected link in a new tab
When I run :window-only
And I run :jseval --file (testdata)/search_select.js
And I run :follow-selected -t
And I wait until data/hello.txt is loaded
Then the following tabs should be open:
- data/search.html
- data/hello.txt (active)