Commit 370fe800 authored by Robert Knight's avatar Robert Knight

Add test to check `describe` fails when selection spans multiple pages

parent fe5a3987
......@@ -108,16 +108,18 @@ function createPage(content, rendered) {
/**
* Set the index of the page which is currently visible in the viewport.
*
* The page which is visible will be "rendered" and have a text layer available.
* For other pages, there will only be a placeholder element for the whole page.
* Pages from `index` up to and including `lastRenderedPage` will be
* "rendered" and have a text layer available. Other pages will be "un-rendered"
* with no text layer available, but only a placeholder element for the whole
* page.
*/
FakePDFViewerApplication.prototype.setCurrentPage = function (index) {
FakePDFViewerApplication.prototype.setCurrentPage = function (index, lastRenderedPage=index) {
const self = this;
this._checkBounds(index);
const pages = this._content.map(function (text, idx) {
return createPage(text, idx === index /* rendered */);
return createPage(text, idx >= index && idx <= lastRenderedPage);
});
this._container.innerHTML = '';
......
......@@ -134,6 +134,15 @@ describe('annotator.anchoring.pdf', function () {
assert.equal(position.end, expectedPos + quote.length);
});
});
it('rejects when text selection spans multiple pages', () => {
viewer.setCurrentPage(2, 3);
const range = findText(container, 'occupied again? NODE A');
return pdfAnchoring.describe(container, range).catch(err => {
assert.equal(err.message, 'selecting across page breaks is not supported');
});
});
});
describe('#anchor', function () {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment