@internetarchive/bookreader 5.0.0-18
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.eslintrc.js +58 -0
- package/.gitattributes +2 -0
- package/.github/ISSUE_TEMPLATE/bug.md +32 -0
- package/.github/ISSUE_TEMPLATE/feature-request.md +30 -0
- package/.github/PULL_REQUEST_TEMPLATE/pull_request_template.md +15 -0
- package/.github/dependabot.yml +8 -0
- package/.github/workflows/node.js.yml +37 -0
- package/.github/workflows/npm-publish.yml +47 -0
- package/.testcaferc.json +5 -0
- package/BookReader/BookReader.css +2983 -0
- package/BookReader/BookReader.js +3 -0
- package/BookReader/BookReader.js.LICENSE.txt +117 -0
- package/BookReader/BookReader.js.map +1 -0
- package/BookReader/bookreader-component-bundle.js +1436 -0
- package/BookReader/bookreader-component-bundle.js.LICENSE.txt +27 -0
- package/BookReader/bookreader-component-bundle.js.map +1 -0
- package/BookReader/icons/1up.svg +1 -0
- package/BookReader/icons/2up.svg +1 -0
- package/BookReader/icons/advance.svg +3 -0
- package/BookReader/icons/chevron-right.svg +1 -0
- package/BookReader/icons/close-circle-dark.svg +1 -0
- package/BookReader/icons/close-circle.svg +1 -0
- package/BookReader/icons/fullscreen.svg +1 -0
- package/BookReader/icons/fullscreen_exit.svg +1 -0
- package/BookReader/icons/hamburger.svg +1 -0
- package/BookReader/icons/left-arrow.svg +1 -0
- package/BookReader/icons/magnify-minus.svg +1 -0
- package/BookReader/icons/magnify-plus.svg +1 -0
- package/BookReader/icons/magnify.svg +1 -0
- package/BookReader/icons/pause.svg +1 -0
- package/BookReader/icons/play.svg +1 -0
- package/BookReader/icons/playback-speed.svg +1 -0
- package/BookReader/icons/read-aloud.svg +1 -0
- package/BookReader/icons/review.svg +3 -0
- package/BookReader/icons/thumbnails.svg +1 -0
- package/BookReader/icons/volume-full.svg +1 -0
- package/BookReader/images/BRicons.png +0 -0
- package/BookReader/images/BRicons.svg +5 -0
- package/BookReader/images/BRicons_ia.png +0 -0
- package/BookReader/images/back_pages.png +0 -0
- package/BookReader/images/book_bottom_icon.png +0 -0
- package/BookReader/images/book_down_icon.png +0 -0
- package/BookReader/images/book_left_icon.png +0 -0
- package/BookReader/images/book_leftmost_icon.png +0 -0
- package/BookReader/images/book_right_icon.png +0 -0
- package/BookReader/images/book_rightmost_icon.png +0 -0
- package/BookReader/images/book_top_icon.png +0 -0
- package/BookReader/images/book_up_icon.png +0 -0
- package/BookReader/images/books_graphic.svg +1 -0
- package/BookReader/images/booksplit.png +0 -0
- package/BookReader/images/control_pause_icon.png +0 -0
- package/BookReader/images/control_play_icon.png +0 -0
- package/BookReader/images/embed_icon.png +0 -0
- package/BookReader/images/icon-home-ia.png +0 -0
- package/BookReader/images/icon_OL-logo-xs.png +0 -0
- package/BookReader/images/icon_alert-xs.png +0 -0
- package/BookReader/images/icon_book.svg +1 -0
- package/BookReader/images/icon_bookmark.svg +1 -0
- package/BookReader/images/icon_close-pop.png +0 -0
- package/BookReader/images/icon_download.png +0 -0
- package/BookReader/images/icon_gear.svg +1 -0
- package/BookReader/images/icon_hamburger.svg +1 -0
- package/BookReader/images/icon_home.png +0 -0
- package/BookReader/images/icon_home.svg +1 -0
- package/BookReader/images/icon_home_ia.png +0 -0
- package/BookReader/images/icon_indicator.png +0 -0
- package/BookReader/images/icon_info.svg +1 -0
- package/BookReader/images/icon_one_page.svg +1 -0
- package/BookReader/images/icon_pause.svg +1 -0
- package/BookReader/images/icon_play.svg +1 -0
- package/BookReader/images/icon_playback-rate.svg +1 -0
- package/BookReader/images/icon_return.png +0 -0
- package/BookReader/images/icon_search_button.svg +1 -0
- package/BookReader/images/icon_share.svg +1 -0
- package/BookReader/images/icon_skip-ahead.svg +1 -0
- package/BookReader/images/icon_skip-back.svg +2 -0
- package/BookReader/images/icon_speaker.svg +1 -0
- package/BookReader/images/icon_speaker_open.svg +1 -0
- package/BookReader/images/icon_thumbnails.svg +1 -0
- package/BookReader/images/icon_toc.svg +1 -0
- package/BookReader/images/icon_two_pages.svg +1 -0
- package/BookReader/images/icon_zoomer.png +0 -0
- package/BookReader/images/loading.gif +0 -0
- package/BookReader/images/logo_icon.png +0 -0
- package/BookReader/images/marker_chap-off.png +0 -0
- package/BookReader/images/marker_chap-off.svg +1 -0
- package/BookReader/images/marker_chap-off_ia.png +0 -0
- package/BookReader/images/marker_chap-on.png +0 -0
- package/BookReader/images/marker_chap-on.svg +1 -0
- package/BookReader/images/marker_srch-on.svg +1 -0
- package/BookReader/images/marker_srchchap-off.png +0 -0
- package/BookReader/images/marker_srchchap-on.png +0 -0
- package/BookReader/images/nav_control-dn.png +0 -0
- package/BookReader/images/nav_control-dn_ia.png +0 -0
- package/BookReader/images/nav_control-up.png +0 -0
- package/BookReader/images/nav_control-up_ia.png +0 -0
- package/BookReader/images/nav_control.png +0 -0
- package/BookReader/images/one_page_mode_icon.png +0 -0
- package/BookReader/images/paper-badge.png +0 -0
- package/BookReader/images/print_icon.png +0 -0
- package/BookReader/images/progressbar.gif +0 -0
- package/BookReader/images/right_edges.png +0 -0
- package/BookReader/images/slider.png +0 -0
- package/BookReader/images/slider_ia.png +0 -0
- package/BookReader/images/thumbnail_mode_icon.png +0 -0
- package/BookReader/images/transparent.png +0 -0
- package/BookReader/images/two_page_mode_icon.png +0 -0
- package/BookReader/images/zoom_in_icon.png +0 -0
- package/BookReader/images/zoom_out_icon.png +0 -0
- package/BookReader/jquery-1.10.1.js +2 -0
- package/BookReader/jquery-1.10.1.js.LICENSE.txt +24 -0
- package/BookReader/plugins/plugin.archive_analytics.js +2 -0
- package/BookReader/plugins/plugin.archive_analytics.js.map +1 -0
- package/BookReader/plugins/plugin.autoplay.js +2 -0
- package/BookReader/plugins/plugin.autoplay.js.map +1 -0
- package/BookReader/plugins/plugin.chapters.js +2 -0
- package/BookReader/plugins/plugin.chapters.js.map +1 -0
- package/BookReader/plugins/plugin.iframe.js +2 -0
- package/BookReader/plugins/plugin.iframe.js.map +1 -0
- package/BookReader/plugins/plugin.mobile_nav.js +2 -0
- package/BookReader/plugins/plugin.mobile_nav.js.map +1 -0
- package/BookReader/plugins/plugin.resume.js +2 -0
- package/BookReader/plugins/plugin.resume.js.map +1 -0
- package/BookReader/plugins/plugin.search.js +2 -0
- package/BookReader/plugins/plugin.search.js.map +1 -0
- package/BookReader/plugins/plugin.text_selection.js +2 -0
- package/BookReader/plugins/plugin.text_selection.js.map +1 -0
- package/BookReader/plugins/plugin.tts.js +3 -0
- package/BookReader/plugins/plugin.tts.js.LICENSE.txt +27 -0
- package/BookReader/plugins/plugin.tts.js.map +1 -0
- package/BookReader/plugins/plugin.url.js +2 -0
- package/BookReader/plugins/plugin.url.js.map +1 -0
- package/BookReader/plugins/plugin.vendor-fullscreen.js +2 -0
- package/BookReader/plugins/plugin.vendor-fullscreen.js.map +1 -0
- package/BookReaderDemo/BookReaderDemo.css +41 -0
- package/BookReaderDemo/BookReaderJSAdvanced.js +115 -0
- package/BookReaderDemo/BookReaderJSAutoplay.js +56 -0
- package/BookReaderDemo/BookReaderJSSimple.js +55 -0
- package/BookReaderDemo/IIIFBookReader.js +207 -0
- package/BookReaderDemo/assets/v5/Bookreader-logo-cool-grad.svg +1 -0
- package/BookReaderDemo/assets/v5/Bookreader-logo-flat.svg +1 -0
- package/BookReaderDemo/assets/v5/Bookreader-logo-hex-cool-grad.png +0 -0
- package/BookReaderDemo/assets/v5/Bookreader-logo-hex-flat.png +0 -0
- package/BookReaderDemo/assets/v5/Bookreader-logo-lines.png +0 -0
- package/BookReaderDemo/assets/v5/Bookreader-logo-lines.svg +1 -0
- package/BookReaderDemo/assets/v5/Bookreader-logo-warm.svg +1 -0
- package/BookReaderDemo/assets/v5/bookreader-logo-renders@1x.png +0 -0
- package/BookReaderDemo/assets/v5/bookreader-logo-renders@2x.png +0 -0
- package/BookReaderDemo/assets/v5/bookreader-v5-screenshot.png +0 -0
- package/BookReaderDemo/bookreader-template-bundle.js +7178 -0
- package/BookReaderDemo/demo-advanced.html +32 -0
- package/BookReaderDemo/demo-autoplay.html +38 -0
- package/BookReaderDemo/demo-embed-iframe-src.html +84 -0
- package/BookReaderDemo/demo-embed.html +26 -0
- package/BookReaderDemo/demo-fullscreen-mobile.html +36 -0
- package/BookReaderDemo/demo-fullscreen.html +33 -0
- package/BookReaderDemo/demo-iiif.html +34 -0
- package/BookReaderDemo/demo-iiif.js +26 -0
- package/BookReaderDemo/demo-internetarchive.html +74 -0
- package/BookReaderDemo/demo-multiple.html +43 -0
- package/BookReaderDemo/demo-preview-pages.html +1092 -0
- package/BookReaderDemo/demo-simple.html +34 -0
- package/BookReaderDemo/demo-vendor-fullscreen.html +36 -0
- package/BookReaderDemo/immersion-1up.html +64 -0
- package/BookReaderDemo/immersion-mode.html +35 -0
- package/BookReaderDemo/toggle_controls.html +53 -0
- package/BookReaderDemo/view_mode.html +39 -0
- package/BookReaderDemo/viewmode-cycle.html +41 -0
- package/CHANGELOG.md +540 -0
- package/CONTRIBUTING.md +7 -0
- package/LICENSE +661 -0
- package/README.md +205 -0
- package/babel.config.js +18 -0
- package/codecov.yml +17 -0
- package/index.html +31 -0
- package/jsconfig.json +14 -0
- package/karma.conf.js +23 -0
- package/package.json +129 -0
- package/screenshot.png +0 -0
- package/scripts/postversion.js +10 -0
- package/scripts/preversion.js +14 -0
- package/scripts/version.js +26 -0
- package/src/BookNavigator/BookModel.js +14 -0
- package/src/BookNavigator/BookNavigator.js +468 -0
- package/src/BookNavigator/assets/book-loader.js +27 -0
- package/src/BookNavigator/assets/bookmark-colors.js +15 -0
- package/src/BookNavigator/assets/button-base.js +61 -0
- package/src/BookNavigator/assets/icon_checkmark.js +6 -0
- package/src/BookNavigator/assets/icon_close.js +3 -0
- package/src/BookNavigator/assets/icon_sort_asc.js +5 -0
- package/src/BookNavigator/assets/icon_sort_desc.js +5 -0
- package/src/BookNavigator/assets/icon_sort_neutral.js +5 -0
- package/src/BookNavigator/assets/icon_volumes.js +11 -0
- package/src/BookNavigator/bookmarks/bookmark-button.js +64 -0
- package/src/BookNavigator/bookmarks/bookmark-edit.js +215 -0
- package/src/BookNavigator/bookmarks/bookmarks-list.js +285 -0
- package/src/BookNavigator/bookmarks/bookmarks-loginCTA.js +28 -0
- package/src/BookNavigator/bookmarks/bookmarks-provider.js +53 -0
- package/src/BookNavigator/bookmarks/ia-bookmarks.js +500 -0
- package/src/BookNavigator/br-fullscreen-mgr.js +83 -0
- package/src/BookNavigator/delete-modal-actions.js +49 -0
- package/src/BookNavigator/downloads/downloads-provider.js +76 -0
- package/src/BookNavigator/downloads/downloads.js +138 -0
- package/src/BookNavigator/search/a-search-result.js +55 -0
- package/src/BookNavigator/search/search-provider.js +180 -0
- package/src/BookNavigator/search/search-results.js +360 -0
- package/src/BookNavigator/visual-adjustments/visual-adjustments-provider.js +93 -0
- package/src/BookNavigator/visual-adjustments/visual-adjustments.js +280 -0
- package/src/BookNavigator/volumes/volumes-provider.js +83 -0
- package/src/BookNavigator/volumes/volumes.js +178 -0
- package/src/BookReader/BookModel.js +518 -0
- package/src/BookReader/DebugConsole.js +54 -0
- package/src/BookReader/ImageCache.js +116 -0
- package/src/BookReader/Mode1Up.js +90 -0
- package/src/BookReader/Mode1UpLit.js +434 -0
- package/src/BookReader/Mode2Up.js +1372 -0
- package/src/BookReader/ModeSmoothZoom.js +177 -0
- package/src/BookReader/ModeThumb.js +336 -0
- package/src/BookReader/Navbar/Navbar.js +339 -0
- package/src/BookReader/PageContainer.js +120 -0
- package/src/BookReader/ReduceSet.js +26 -0
- package/src/BookReader/Toolbar/Toolbar.js +384 -0
- package/src/BookReader/events.js +20 -0
- package/src/BookReader/options.js +320 -0
- package/src/BookReader/utils/HTMLDimensionsCacher.js +44 -0
- package/src/BookReader/utils/classes.js +36 -0
- package/src/BookReader/utils.js +240 -0
- package/src/BookReader.js +2546 -0
- package/src/BookReaderComponent/BookReaderComponent.js +112 -0
- package/src/ItemNavigator/ItemNavigator.js +376 -0
- package/src/ItemNavigator/providers/sharing.js +33 -0
- package/src/assets/icons/1up.svg +12 -0
- package/src/assets/icons/2up.svg +15 -0
- package/src/assets/icons/advance.svg +26 -0
- package/src/assets/icons/chevron-right.svg +1 -0
- package/src/assets/icons/close-circle-dark.svg +1 -0
- package/src/assets/icons/close-circle.svg +1 -0
- package/src/assets/icons/fullscreen.svg +17 -0
- package/src/assets/icons/fullscreen_exit.svg +17 -0
- package/src/assets/icons/hamburger.svg +15 -0
- package/src/assets/icons/left-arrow.svg +12 -0
- package/src/assets/icons/magnify-minus.svg +16 -0
- package/src/assets/icons/magnify-plus.svg +17 -0
- package/src/assets/icons/magnify.svg +15 -0
- package/src/assets/icons/pause.svg +23 -0
- package/src/assets/icons/play.svg +22 -0
- package/src/assets/icons/playback-speed.svg +34 -0
- package/src/assets/icons/read-aloud.svg +22 -0
- package/src/assets/icons/review.svg +22 -0
- package/src/assets/icons/thumbnails.svg +17 -0
- package/src/assets/icons/volume-full.svg +22 -0
- package/src/assets/images/BRicons.png +0 -0
- package/src/assets/images/BRicons.svg +94 -0
- package/src/assets/images/BRicons_ia.png +0 -0
- package/src/assets/images/back_pages.png +0 -0
- package/src/assets/images/book_bottom_icon.png +0 -0
- package/src/assets/images/book_down_icon.png +0 -0
- package/src/assets/images/book_left_icon.png +0 -0
- package/src/assets/images/book_leftmost_icon.png +0 -0
- package/src/assets/images/book_right_icon.png +0 -0
- package/src/assets/images/book_rightmost_icon.png +0 -0
- package/src/assets/images/book_top_icon.png +0 -0
- package/src/assets/images/book_up_icon.png +0 -0
- package/src/assets/images/books_graphic.svg +177 -0
- package/src/assets/images/booksplit.png +0 -0
- package/src/assets/images/control_pause_icon.png +0 -0
- package/src/assets/images/control_play_icon.png +0 -0
- package/src/assets/images/embed_icon.png +0 -0
- package/src/assets/images/icon-home-ia.png +0 -0
- package/src/assets/images/icon_OL-logo-xs.png +0 -0
- package/src/assets/images/icon_alert-xs.png +0 -0
- package/src/assets/images/icon_book.svg +12 -0
- package/src/assets/images/icon_bookmark.svg +12 -0
- package/src/assets/images/icon_close-pop.png +0 -0
- package/src/assets/images/icon_download.png +0 -0
- package/src/assets/images/icon_gear.svg +14 -0
- package/src/assets/images/icon_hamburger.svg +20 -0
- package/src/assets/images/icon_home.png +0 -0
- package/src/assets/images/icon_home.svg +21 -0
- package/src/assets/images/icon_home_ia.png +0 -0
- package/src/assets/images/icon_indicator.png +0 -0
- package/src/assets/images/icon_info.svg +11 -0
- package/src/assets/images/icon_one_page.svg +8 -0
- package/src/assets/images/icon_pause.svg +1 -0
- package/src/assets/images/icon_play.svg +1 -0
- package/src/assets/images/icon_playback-rate.svg +15 -0
- package/src/assets/images/icon_return.png +0 -0
- package/src/assets/images/icon_search_button.svg +8 -0
- package/src/assets/images/icon_share.svg +9 -0
- package/src/assets/images/icon_skip-ahead.svg +6 -0
- package/src/assets/images/icon_skip-back.svg +13 -0
- package/src/assets/images/icon_speaker.svg +18 -0
- package/src/assets/images/icon_speaker_open.svg +10 -0
- package/src/assets/images/icon_thumbnails.svg +12 -0
- package/src/assets/images/icon_toc.svg +5 -0
- package/src/assets/images/icon_two_pages.svg +9 -0
- package/src/assets/images/icon_zoomer.png +0 -0
- package/src/assets/images/loading.gif +0 -0
- package/src/assets/images/logo_icon.png +0 -0
- package/src/assets/images/marker_chap-off.png +0 -0
- package/src/assets/images/marker_chap-off.svg +11 -0
- package/src/assets/images/marker_chap-off_ia.png +0 -0
- package/src/assets/images/marker_chap-on.png +0 -0
- package/src/assets/images/marker_chap-on.svg +11 -0
- package/src/assets/images/marker_srch-on.svg +11 -0
- package/src/assets/images/marker_srchchap-off.png +0 -0
- package/src/assets/images/marker_srchchap-on.png +0 -0
- package/src/assets/images/nav_control-dn.png +0 -0
- package/src/assets/images/nav_control-dn_ia.png +0 -0
- package/src/assets/images/nav_control-up.png +0 -0
- package/src/assets/images/nav_control-up_ia.png +0 -0
- package/src/assets/images/nav_control.png +0 -0
- package/src/assets/images/one_page_mode_icon.png +0 -0
- package/src/assets/images/paper-badge.png +0 -0
- package/src/assets/images/print_icon.png +0 -0
- package/src/assets/images/progressbar.gif +0 -0
- package/src/assets/images/right_edges.png +0 -0
- package/src/assets/images/slider.png +0 -0
- package/src/assets/images/slider_ia.png +0 -0
- package/src/assets/images/thumbnail_mode_icon.png +0 -0
- package/src/assets/images/transparent.png +0 -0
- package/src/assets/images/two_page_mode_icon.png +0 -0
- package/src/assets/images/zoom_in_icon.png +0 -0
- package/src/assets/images/zoom_out_icon.png +0 -0
- package/src/css/BookReader.scss +89 -0
- package/src/css/_BRBookmarks.scss +29 -0
- package/src/css/_BRComponent.scss +13 -0
- package/src/css/_BRfloat.scss +197 -0
- package/src/css/_BRicon.scss +48 -0
- package/src/css/_BRmain.scss +251 -0
- package/src/css/_BRnav.scss +382 -0
- package/src/css/_BRpages.scss +139 -0
- package/src/css/_BRsearch.scss +226 -0
- package/src/css/_BRtoolbar.scss +84 -0
- package/src/css/_BRvendor.scss +5 -0
- package/src/css/_MobileNav.scss +194 -0
- package/src/css/_TextSelection.scss +32 -0
- package/src/css/_colorbox.scss +52 -0
- package/src/css/_controls.scss +244 -0
- package/src/css/_icons.scss +121 -0
- package/src/dragscrollable-br.js +261 -0
- package/src/jquery-wrapper.js +4 -0
- package/src/plugins/plugin.archive_analytics.js +86 -0
- package/src/plugins/plugin.autoplay.js +129 -0
- package/src/plugins/plugin.chapters.js +251 -0
- package/src/plugins/plugin.iframe.js +48 -0
- package/src/plugins/plugin.mobile_nav.js +287 -0
- package/src/plugins/plugin.resume.js +68 -0
- package/src/plugins/plugin.text_selection.js +291 -0
- package/src/plugins/plugin.url.js +198 -0
- package/src/plugins/plugin.vendor-fullscreen.js +247 -0
- package/src/plugins/search/plugin.search.js +439 -0
- package/src/plugins/search/view.js +440 -0
- package/src/plugins/tts/AbstractTTSEngine.js +242 -0
- package/src/plugins/tts/FestivalTTSEngine.js +169 -0
- package/src/plugins/tts/PageChunk.js +107 -0
- package/src/plugins/tts/PageChunkIterator.js +163 -0
- package/src/plugins/tts/WebTTSEngine.js +352 -0
- package/src/plugins/tts/plugin.tts.js +335 -0
- package/src/plugins/tts/tooltip_dict.js +15 -0
- package/src/plugins/tts/utils.js +91 -0
- package/src/util/browserSniffing.js +30 -0
- package/src/util/debouncer.js +26 -0
- package/src/util/docCookies.js +67 -0
- package/src/util/strings.js +34 -0
- package/tests/BookReader/BookModel.test.js +312 -0
- package/tests/BookReader/BookReaderPublicFunctions.test.js +164 -0
- package/tests/BookReader/DebugConsole.test.js +25 -0
- package/tests/BookReader/ImageCache.test.js +150 -0
- package/tests/BookReader/Mode1UpLit.test.js +87 -0
- package/tests/BookReader/Mode2Up.test.js +245 -0
- package/tests/BookReader/ModeSmoothZoom.test.js +149 -0
- package/tests/BookReader/Navbar/Navbar.test.js +169 -0
- package/tests/BookReader/PageContainer.test.js +187 -0
- package/tests/BookReader/ReduceSet.test.js +38 -0
- package/tests/BookReader/Toolbar/Toolbar.test.js +26 -0
- package/tests/BookReader/utils/HTMLDimensionsCacher.test.js +59 -0
- package/tests/BookReader/utils/classes.test.js +88 -0
- package/tests/BookReader/utils.test.js +136 -0
- package/tests/BookReader.options.test.js +39 -0
- package/tests/BookReader.test.js +301 -0
- package/tests/e2e/README.md +75 -0
- package/tests/e2e/autoplay.test.js +13 -0
- package/tests/e2e/base.test.js +35 -0
- package/tests/e2e/helpers/base.js +263 -0
- package/tests/e2e/helpers/debug.js +13 -0
- package/tests/e2e/helpers/desktopSearch.js +72 -0
- package/tests/e2e/helpers/mobileSearch.js +85 -0
- package/tests/e2e/helpers/mockSearch.js +93 -0
- package/tests/e2e/helpers/rightToLeft.js +29 -0
- package/tests/e2e/ia-production/ia-prod-base.js +17 -0
- package/tests/e2e/models/BookReader.js +11 -0
- package/tests/e2e/models/Navigation.js +56 -0
- package/tests/e2e/rightToLeft.test.js +20 -0
- package/tests/e2e/viewmode.test.js +37 -0
- package/tests/karma/BookNavigator/book-navigator.test.js +180 -0
- package/tests/karma/BookNavigator/bookmarks/bookmark-edit.test.js +133 -0
- package/tests/karma/BookNavigator/bookmarks/bookmarks-list.test.js +222 -0
- package/tests/karma/BookNavigator/downloads/downloads-provider.test.js +64 -0
- package/tests/karma/BookNavigator/downloads/downloads.test.js +54 -0
- package/tests/karma/BookNavigator/search/search-provider.test.js +23 -0
- package/tests/karma/BookNavigator/search/search-results.test.js +240 -0
- package/tests/karma/BookNavigator/sharing/sharing-provider.test.js +40 -0
- package/tests/karma/BookNavigator/visual-adjustments.test.js +201 -0
- package/tests/karma/BookNavigator/volumes/volumes-provider.test.js +160 -0
- package/tests/karma/BookNavigator/volumes/volumes.test.js +98 -0
- package/tests/plugins/plugin.archive_analytics.test.js +23 -0
- package/tests/plugins/plugin.autoplay.test.js +52 -0
- package/tests/plugins/plugin.chapters.test.js +130 -0
- package/tests/plugins/plugin.iframe.test.js +42 -0
- package/tests/plugins/plugin.mobile_nav.test.js +66 -0
- package/tests/plugins/plugin.resume.test.js +98 -0
- package/tests/plugins/plugin.text_selection.test.js +193 -0
- package/tests/plugins/plugin.url.test.js +129 -0
- package/tests/plugins/plugin.vendor-fullscreen.test.js +65 -0
- package/tests/plugins/search/plugin.search.test.js +173 -0
- package/tests/plugins/search/plugin.search.view.test.js +106 -0
- package/tests/plugins/tts/AbstractTTSEngine.test.js +153 -0
- package/tests/plugins/tts/FestivalTTSEngine.test.js +59 -0
- package/tests/plugins/tts/PageChunk.test.js +57 -0
- package/tests/plugins/tts/PageChunkIterator.test.js +179 -0
- package/tests/plugins/tts/WebTTSEngine.test.js +126 -0
- package/tests/plugins/tts/utils.test.js +133 -0
- package/tests/util/browserSniffing.test.js +56 -0
- package/tests/util/docCookies.test.js +15 -0
- package/tests/util/strings.test.js +63 -0
- package/tests/utils.js +80 -0
- package/webpack.config.js +85 -0
@@ -0,0 +1,13 @@
|
|
1
|
+
/**
|
2
|
+
* Enables a debugging breakpoint in TestCafe tests
|
3
|
+
*
|
4
|
+
* Usage:
|
5
|
+
* import debug from './helpers/debug';
|
6
|
+
*
|
7
|
+
* test(`does a thing`, async (t) => {
|
8
|
+
* await debug(t);
|
9
|
+
* });
|
10
|
+
*/
|
11
|
+
export default async (t) => {
|
12
|
+
await t.debug().setNativeDialogHandler(() => true);
|
13
|
+
};
|
@@ -0,0 +1,72 @@
|
|
1
|
+
import { ClientFunction, RequestMock } from 'testcafe';
|
2
|
+
import { SEARCH_INSIDE_URL_RE , mockResponseFound, mockResponseNotFound,
|
3
|
+
TEST_TEXT_FOUND, TEST_TEXT_NOT_FOUND, PAGE_FIRST_RESULT, SEARCH_MATCHES_LENGTH } from './mockSearch';
|
4
|
+
|
5
|
+
|
6
|
+
export function runDesktopSearchTests(br) {
|
7
|
+
//building mock response for successful and unsuccessful search
|
8
|
+
const mockFound = RequestMock()
|
9
|
+
.onRequestTo(SEARCH_INSIDE_URL_RE )
|
10
|
+
.respond(mockResponseFound, 202);
|
11
|
+
|
12
|
+
const mockNotFound = RequestMock()
|
13
|
+
.onRequestTo(SEARCH_INSIDE_URL_RE )
|
14
|
+
.respond(mockResponseNotFound, 202);
|
15
|
+
|
16
|
+
|
17
|
+
test
|
18
|
+
.requestHooks(mockFound)('Desktop search - successful search', async t => {
|
19
|
+
const nav = br.nav;
|
20
|
+
|
21
|
+
//assuring that the search bar is enabled
|
22
|
+
await t.expect(nav.desktop.searchBox.visible).ok();
|
23
|
+
|
24
|
+
//testing search for a word found in the book
|
25
|
+
await t
|
26
|
+
.selectText(nav.desktop.searchBox.child('.BRsearchInput'))
|
27
|
+
.pressKey('delete');
|
28
|
+
await t.typeText(nav.desktop.searchBox.child('.BRsearchInput'), TEST_TEXT_FOUND);
|
29
|
+
await t.click((nav.desktop.searchBox).child('.BRsearchSubmit'));
|
30
|
+
await t.expect(nav.desktop.searchPin.exists).ok();
|
31
|
+
await t.expect(nav.desktop.searchPin.child('.BRquery').child('div').exists).ok();
|
32
|
+
await t.expect(nav.desktop.searchPin.child('.BRquery').child('div').innerText).contains(TEST_TEXT_FOUND);
|
33
|
+
await t.expect(nav.desktop.searchNavigation.exists).ok();
|
34
|
+
await t.expect(nav.desktop.searchNavigation.find('[data-id="resultsCount"]').exists).ok();
|
35
|
+
await t.expect(nav.desktop.searchNavigation.find('[data-id="resultsCount"]').innerText).contains(SEARCH_MATCHES_LENGTH);
|
36
|
+
|
37
|
+
//checking url
|
38
|
+
const getPageUrl = ClientFunction(() => window.location.href.toString());
|
39
|
+
await t.expect(getPageUrl()).contains(TEST_TEXT_FOUND);
|
40
|
+
|
41
|
+
//checks clicking on first search pin opens correct page
|
42
|
+
await t.click(nav.desktop.searchPin);
|
43
|
+
await t.expect(getPageUrl()).contains(PAGE_FIRST_RESULT);
|
44
|
+
|
45
|
+
//checks highlight on result page is visible
|
46
|
+
const highlight = br.shell.find(".searchHiliteLayer rect");
|
47
|
+
await t.expect(highlight.visible).ok();
|
48
|
+
|
49
|
+
});
|
50
|
+
|
51
|
+
|
52
|
+
test
|
53
|
+
.requestHooks(mockNotFound)('Desktop search - unsuccessful search', async t => {
|
54
|
+
const nav = br.nav;
|
55
|
+
|
56
|
+
//assuring that the search bar is enabled
|
57
|
+
await t.expect(nav.desktop.searchBox.visible).ok();
|
58
|
+
|
59
|
+
//testing search for a word not found in the book
|
60
|
+
await t
|
61
|
+
.selectText(nav.desktop.searchBox.child('.BRsearchInput'))
|
62
|
+
.pressKey('delete');
|
63
|
+
await t.typeText(nav.desktop.searchBox.child('.BRsearchInput'), TEST_TEXT_NOT_FOUND);
|
64
|
+
await t.click((nav.desktop.searchBox).child('.BRsearchSubmit'));
|
65
|
+
await t.expect(nav.desktop.searchPin.child('.BRquery').child('div').withText(TEST_TEXT_NOT_FOUND).exists).notOk();
|
66
|
+
|
67
|
+
const getPageUrl = ClientFunction(() => window.location.href.toString());
|
68
|
+
await t.expect(getPageUrl()).contains(TEST_TEXT_NOT_FOUND);
|
69
|
+
});
|
70
|
+
|
71
|
+
|
72
|
+
}
|
@@ -0,0 +1,85 @@
|
|
1
|
+
import { ClientFunction, RequestMock } from 'testcafe';
|
2
|
+
import { SEARCH_INSIDE_URL_RE , mockResponseFound, mockResponseNotFound,
|
3
|
+
TEST_TEXT_FOUND, TEST_TEXT_NOT_FOUND, PAGE_FIRST_RESULT } from './mockSearch';
|
4
|
+
|
5
|
+
|
6
|
+
export function runMobileSearchTests(br) {
|
7
|
+
//building mock response for successful and unsuccessful search
|
8
|
+
const mockFound = RequestMock()
|
9
|
+
.onRequestTo(SEARCH_INSIDE_URL_RE )
|
10
|
+
.respond(mockResponseFound, 202);
|
11
|
+
|
12
|
+
const mockNotFound = RequestMock()
|
13
|
+
.onRequestTo(SEARCH_INSIDE_URL_RE )
|
14
|
+
.respond(mockResponseNotFound, 202);
|
15
|
+
|
16
|
+
test
|
17
|
+
.requestHooks(mockFound)('Mobile search - successful search', async t => {
|
18
|
+
await t.resizeWindowToFitDevice('Sony Xperia Z', {portraitOrientation: true});
|
19
|
+
const nav = br.nav.mobile;
|
20
|
+
|
21
|
+
//opening side menu and search
|
22
|
+
await t.expect(nav.hamburgerButton.visible).ok();
|
23
|
+
await t.click(nav.hamburgerButton);
|
24
|
+
await t.expect(nav.menuSearchButton.visible).ok();
|
25
|
+
await t.click(nav.menuSearchButton);
|
26
|
+
|
27
|
+
//assuring that the search bar is enabled
|
28
|
+
await t.expect(nav.searchBox.visible).ok();
|
29
|
+
|
30
|
+
//testing successful search
|
31
|
+
await t
|
32
|
+
.selectText(nav.searchBox.find('[name="query"]'))
|
33
|
+
.pressKey('delete');
|
34
|
+
await t
|
35
|
+
.typeText(nav.searchBox.find('[name="query"]'), TEST_TEXT_FOUND)
|
36
|
+
.pressKey('enter');
|
37
|
+
await t.expect(nav.searchResults.visible).ok();
|
38
|
+
await t.expect(nav.searchResultText.exists).ok();
|
39
|
+
await t.expect(nav.searchResultText.innerText).contains(TEST_TEXT_FOUND);
|
40
|
+
|
41
|
+
//checking url
|
42
|
+
const getPageUrl = ClientFunction(() => window.location.href);
|
43
|
+
await t.expect(getPageUrl()).contains(TEST_TEXT_FOUND);
|
44
|
+
|
45
|
+
//checks clicking on first search result opens correct page
|
46
|
+
await t.click(nav.searchResults.child(0));
|
47
|
+
await t.expect(getPageUrl()).contains(PAGE_FIRST_RESULT);
|
48
|
+
|
49
|
+
//checks highlight on result page is visible
|
50
|
+
const highlight = br.shell.find(".searchHiliteLayer rect");
|
51
|
+
await t.expect(highlight.visible).ok();
|
52
|
+
|
53
|
+
await t.maximizeWindow();
|
54
|
+
});
|
55
|
+
|
56
|
+
test
|
57
|
+
.requestHooks(mockNotFound)('Mobile search - unsuccessful search', async t => {
|
58
|
+
await t.resizeWindowToFitDevice('Sony Xperia Z', {portraitOrientation: true});
|
59
|
+
const nav = br.nav.mobile;
|
60
|
+
|
61
|
+
//opening side menu and search
|
62
|
+
await t.expect(nav.hamburgerButton.visible).ok();
|
63
|
+
await t.click(nav.hamburgerButton);
|
64
|
+
await t.expect(nav.menuSearchButton.visible).ok();
|
65
|
+
await t.click(nav.menuSearchButton);
|
66
|
+
|
67
|
+
//assuring that the search bar is enabled
|
68
|
+
await t.expect(nav.searchBox.visible).ok();
|
69
|
+
|
70
|
+
//testing unsuccessful search
|
71
|
+
await t
|
72
|
+
.selectText(nav.searchBox.find('[name="query"]'))
|
73
|
+
.pressKey('delete');
|
74
|
+
await t
|
75
|
+
.typeText(nav.searchBox.find('[name="query"]'), TEST_TEXT_NOT_FOUND)
|
76
|
+
.pressKey('enter');
|
77
|
+
await t.expect(nav.searchResultText.withText(TEST_TEXT_NOT_FOUND).exists).notOk();
|
78
|
+
|
79
|
+
//checking url
|
80
|
+
const getPageUrl = ClientFunction(() => window.location.href.toString());
|
81
|
+
await t.expect(getPageUrl()).contains(TEST_TEXT_NOT_FOUND);
|
82
|
+
await t.maximizeWindow();
|
83
|
+
});
|
84
|
+
|
85
|
+
}
|
@@ -0,0 +1,93 @@
|
|
1
|
+
export const TEST_TEXT_FOUND = 'theory';
|
2
|
+
export const TEST_TEXT_NOT_FOUND = 'HopefullyNotFoundLongWord';
|
3
|
+
export const PAGE_FIRST_RESULT = 30;
|
4
|
+
|
5
|
+
export const SEARCH_INSIDE_URL_RE = /https:\/\/ia[0-9]+\.us\.archive\.org\/fulltext\/inside\.php\?item_id=.*/;
|
6
|
+
|
7
|
+
//adding jQueryxxxxxxxx-xxxxxxxx (semi-random numbers) from request url to returned search request object
|
8
|
+
/** Mock response for a matching search term. */
|
9
|
+
export function mockResponseFound(req, res) {
|
10
|
+
const requestUrl = new URL(req.url);
|
11
|
+
const jqueryUrl = requestUrl.searchParams.get("callback");
|
12
|
+
const wholeString = jqueryUrl + '(' + JSON.stringify(MOCKED_RESPONSE_FOUND) + ')';
|
13
|
+
res.setBody(wholeString);
|
14
|
+
}
|
15
|
+
|
16
|
+
/** Mock response for a matching search term. */
|
17
|
+
export function mockResponseNotFound(req, res) {
|
18
|
+
const requestUrl = new URL(req.url);
|
19
|
+
const jqueryUrl = requestUrl.searchParams.get("callback");
|
20
|
+
const wholeString = jqueryUrl + '(' + JSON.stringify(MOCKED_RESPONSE_NOT_FOUND) + ')';
|
21
|
+
res.setBody(wholeString);
|
22
|
+
}
|
23
|
+
|
24
|
+
const PAGE_FIRST_RESULT_ADJUSTED = PAGE_FIRST_RESULT + 12;
|
25
|
+
//mocked objects inside an unsuccessful search and of a random successful search returned by search requests
|
26
|
+
const MOCKED_RESPONSE_NOT_FOUND = {
|
27
|
+
"ia": "theworksofplato01platiala",
|
28
|
+
"q": TEST_TEXT_NOT_FOUND,
|
29
|
+
"indexed": true,
|
30
|
+
"page_count": 1,
|
31
|
+
"body_length": 666,
|
32
|
+
"leaf0_missing": true,
|
33
|
+
"matches": []
|
34
|
+
};
|
35
|
+
|
36
|
+
const MOCKED_RESPONSE_FOUND = {
|
37
|
+
"ia": "This request has been mocked",
|
38
|
+
"q": TEST_TEXT_FOUND,
|
39
|
+
"indexed": true,
|
40
|
+
"page_count": 644,
|
41
|
+
"body_length": 666,
|
42
|
+
"leaf0_missing": false,
|
43
|
+
"matches": [
|
44
|
+
{
|
45
|
+
"text": "Everybody knows the story of another experimental philosopher who had a great {{{" + TEST_TEXT_FOUND + "}}} about a horse being able to live without eating, and who demonstrated it so well, that he got his own horse down to a straw a day, and would unquestionably have rendered him a very spirited and rampacious animal on nothing at all, if he had not died, four-and-twenty hours before he was to have had his first comfortable bait of air. Unfortunately for the experimental philosophy of the female to whose protecting care Oliver Twist was delivered over, a similar result usually attended the operation of her system; for at the very moment when a child had contrived to exist upon the smallest possible portion of the weakest possible food, it did perversely happen in eight and a half cases out of ten, either that it sickened from want and cold, or fell into the fire from neglect, or got half-smothered by accident; in any one of which cases, the miserable little being was usually summoned into another world, and there gathered to the fathers it had never known in this.",
|
46
|
+
"par": [
|
47
|
+
{
|
48
|
+
"boxes": [
|
49
|
+
{
|
50
|
+
"r": 1045,
|
51
|
+
"b": 811,
|
52
|
+
"t": 753,
|
53
|
+
"page": PAGE_FIRST_RESULT_ADJUSTED,
|
54
|
+
"l": 894
|
55
|
+
}
|
56
|
+
],
|
57
|
+
"b": 1935,
|
58
|
+
"t": 686,
|
59
|
+
"page_width": 1790,
|
60
|
+
"r": 1704,
|
61
|
+
"l": 148,
|
62
|
+
"page_height": 2940,
|
63
|
+
"page": PAGE_FIRST_RESULT_ADJUSTED
|
64
|
+
}
|
65
|
+
]
|
66
|
+
},
|
67
|
+
{
|
68
|
+
"text": "That when the Dodger, and his accomplished friend Master Bates, joined in the hue-and-cry which was raised at Oliver's heels, in consequence of their executing an illegal conveyance of Mr. Brownlow's personal property, as has been already described, they were actuated by a very laudable and becoming regard for themselves ; and forasmuch as the freedom of the subject and the liberty of the individual are among the first and proudest boasts of a true-hearted Englishman, so, I need hardly beg the reader to observe, that this action should tend to exalt them in the opinion of all jniblic and patriotic men, in almost as great a degree as this strong proof of their anxiety for their own preservation and safety goes to corroborate and confirm the little code of laws which certain profound and sound-judging philosophers have laid down as the mainsprings of all Nature's deeds and actions : the said philosophers very wisely reducing the good lady's proceedings to matters of maxim and {{{" + TEST_TEXT_FOUND + "}}} : and, by a very neat and pretty compliment to her exalted wisdom and understanding, putting entirely out of sight any considerations of heart, or generous impulse and feeling. For, these are matters totally beneath a female who is acknowledged by universal admission to be far above the numerous little foibles and weaknesses of her sex.",
|
69
|
+
"par": [
|
70
|
+
{
|
71
|
+
"boxes": [
|
72
|
+
{
|
73
|
+
"r": 593,
|
74
|
+
"b": 2567,
|
75
|
+
"t": 2507,
|
76
|
+
"page": 162,
|
77
|
+
"l": 441
|
78
|
+
}
|
79
|
+
],
|
80
|
+
"b": 2631,
|
81
|
+
"t": 1439,
|
82
|
+
"page_width": 1790,
|
83
|
+
"r": 1620,
|
84
|
+
"l": 56,
|
85
|
+
"page_height": 2940,
|
86
|
+
"page": 162
|
87
|
+
}
|
88
|
+
]
|
89
|
+
}
|
90
|
+
]
|
91
|
+
};
|
92
|
+
|
93
|
+
export const SEARCH_MATCHES_LENGTH = MOCKED_RESPONSE_FOUND.matches.length;
|
@@ -0,0 +1,29 @@
|
|
1
|
+
import { ClientFunction } from 'testcafe';
|
2
|
+
const getPageUrl = ClientFunction(() => window.location.href);
|
3
|
+
|
4
|
+
export function runRightToLeftTests (br) {
|
5
|
+
test('Right to Left - correct initialization in two-page view', async t => {
|
6
|
+
const { nav, BRcontainer} = br;
|
7
|
+
await t.click(nav.desktop.mode2Up);
|
8
|
+
|
9
|
+
//checking right leaf edge has 0 width
|
10
|
+
await t.expect(BRcontainer.find('.BRleafEdgeR').getStyleProperty('width')).eql('0px');
|
11
|
+
|
12
|
+
//checking empty page before the cover is more to the left than the first page
|
13
|
+
const rightEmptyPage = BRcontainer.find('.BRpagecontainer.BRemptypage');
|
14
|
+
const leftPage = BRcontainer.find('.BRpagecontainer.pagediv0');
|
15
|
+
const leftPageLDistance = leftPage.getBoundingClientRectProperty('left');
|
16
|
+
const rightPageLDistance = rightEmptyPage.getBoundingClientRectProperty('left');
|
17
|
+
await t.expect(rightPageLDistance).gt(await leftPageLDistance);
|
18
|
+
|
19
|
+
//checks slider is in correct position
|
20
|
+
await t.expect(nav.desktop.sliderRange.getStyleProperty('width')).eql('0px');
|
21
|
+
});
|
22
|
+
|
23
|
+
test('Right to Left - assuring flipping left goes to next page', async t => {
|
24
|
+
const { nav } = br;
|
25
|
+
await t.click(nav.desktop.mode2Up);
|
26
|
+
await t.click(nav.desktop.goLeft);
|
27
|
+
await t.expect(getPageUrl()).match(/page\/n2/);
|
28
|
+
});
|
29
|
+
}
|
@@ -0,0 +1,17 @@
|
|
1
|
+
import { runBaseTests } from '../helpers/base';
|
2
|
+
import BookReader from '../models/BookReader';
|
3
|
+
|
4
|
+
const localURL = 'https://archive.org/details/';
|
5
|
+
const books = [
|
6
|
+
'birdbookillustra00reedrich', // publicDomain
|
7
|
+
// 'pianoservicingtu00rebl_0', // borrowable,
|
8
|
+
// 'adventuresoftoms00twaiiala', // has chapter markers
|
9
|
+
// 'gendaitankashu00meijuoft', // Right to Left book
|
10
|
+
// 'gov.uspto.patents.application.10074026', // multiple files
|
11
|
+
];
|
12
|
+
|
13
|
+
books.forEach(function(page) {
|
14
|
+
const url = `${localURL}${page}`;
|
15
|
+
fixture `Archive.org BR Base Tests for: ${page}`.page `${url}`;
|
16
|
+
runBaseTests(new BookReader());
|
17
|
+
});
|
@@ -0,0 +1,11 @@
|
|
1
|
+
import { Selector } from 'testcafe';
|
2
|
+
import Nav from './Navigation';
|
3
|
+
|
4
|
+
/** Model defining BookReader base elements */
|
5
|
+
export default class BookReader {
|
6
|
+
constructor () {
|
7
|
+
this.shell = new Selector('.BookReader');
|
8
|
+
this.BRcontainer = new Selector('.BRcontainer');
|
9
|
+
this.nav = new Nav();
|
10
|
+
}
|
11
|
+
}
|
@@ -0,0 +1,56 @@
|
|
1
|
+
import { Selector } from 'testcafe';
|
2
|
+
|
3
|
+
/** Model defining BookReader's Navigation base elements */
|
4
|
+
export default class Navigation {
|
5
|
+
constructor() {
|
6
|
+
this.topNavShell = new Selector('.BRtoolbar');
|
7
|
+
this.bottomNavShell = new Selector('.BRfooter');
|
8
|
+
this.mobileMenu = new Selector('.BRmobileMenu');
|
9
|
+
this.desktop = new DesktopNav(this.bottomNavShell, this.topNavShell);
|
10
|
+
this.mobile = new MobileNav(this.mobileMenu, this.topNavShell);
|
11
|
+
}
|
12
|
+
}
|
13
|
+
|
14
|
+
/**
|
15
|
+
* DesktopNav Model
|
16
|
+
* @class
|
17
|
+
* @classdesc defines DesktopNav base elements
|
18
|
+
*/
|
19
|
+
class DesktopNav {
|
20
|
+
constructor(bottomToolbar, topToolbar) {
|
21
|
+
// flipping
|
22
|
+
this.goLeft = bottomToolbar.find('.BRicon.book_left');
|
23
|
+
this.goRight = bottomToolbar.find('.BRicon.book_right');
|
24
|
+
this.goNext = bottomToolbar.find('.BRicon.book_flip_next');
|
25
|
+
this.goPrev = bottomToolbar.find('.BRicon.book_flip_prev');
|
26
|
+
|
27
|
+
// mode switching
|
28
|
+
this.mode1Up = bottomToolbar.find('.BRicon.onepg');
|
29
|
+
this.mode2Up = bottomToolbar.find('.BRicon.twopg');
|
30
|
+
this.modeThumb = bottomToolbar.find('.BRicon.thumb');
|
31
|
+
this.viewmode = bottomToolbar.find('.BRicon.viewmode');
|
32
|
+
|
33
|
+
// zoom
|
34
|
+
this.zoomIn = bottomToolbar.find('.BRicon.zoom_in');
|
35
|
+
this.zoomOut = bottomToolbar.find('.BRicon.zoom_out');
|
36
|
+
|
37
|
+
// search
|
38
|
+
this.searchBox = topToolbar.find('.BRbooksearch.desktop');
|
39
|
+
this.searchPin = bottomToolbar.find('.BRsearch');
|
40
|
+
this.searchNavigation = bottomToolbar.find('.BRsearch-navigation');
|
41
|
+
|
42
|
+
// other
|
43
|
+
this.fullScreen = bottomToolbar.find('.BRicon.full');
|
44
|
+
this.sliderRange = bottomToolbar.find('.ui-slider-range');
|
45
|
+
}
|
46
|
+
}
|
47
|
+
|
48
|
+
class MobileNav {
|
49
|
+
constructor(mobileMenu, topToolbar) {
|
50
|
+
this.hamburgerButton = topToolbar.find('.BRmobileHamburger');
|
51
|
+
this.menuSearchButton = mobileMenu.find('.BRmobileMenu__search');
|
52
|
+
this.searchBox = mobileMenu.find('#BRsearch_tray');
|
53
|
+
this.searchResults = mobileMenu.find('[data-id="results"]');
|
54
|
+
this.searchResultText = this.searchResults.child(0).find('p');
|
55
|
+
}
|
56
|
+
}
|
@@ -0,0 +1,20 @@
|
|
1
|
+
import { runBaseTests } from './helpers/base';
|
2
|
+
import { runRightToLeftTests } from './helpers/rightToLeft';
|
3
|
+
|
4
|
+
import BookReader from './models/BookReader';
|
5
|
+
|
6
|
+
const { BASE_URL } = process.env;
|
7
|
+
const DEMO_PATH = 'demo-internetarchive.html?ocaid=';
|
8
|
+
const OCAIDS = [
|
9
|
+
'gendaitankashu00meijuoft', // Right to Left book
|
10
|
+
];
|
11
|
+
|
12
|
+
OCAIDS.forEach(ocaid => {
|
13
|
+
const url = `${BASE_URL}${DEMO_PATH}${ocaid}`;
|
14
|
+
|
15
|
+
fixture `Base Tests for right to left book: ${ocaid}`.page `${url}`;
|
16
|
+
runBaseTests(new BookReader({ pageProgression: 'rl' }));
|
17
|
+
|
18
|
+
fixture `Specific Tests for right to left book: ${ocaid}`.page `${url}`;
|
19
|
+
runRightToLeftTests(new BookReader());
|
20
|
+
});
|
@@ -0,0 +1,37 @@
|
|
1
|
+
import { Selector } from 'testcafe';
|
2
|
+
import BookReader from './models/BookReader';
|
3
|
+
|
4
|
+
const { BASE_URL } = process.env;
|
5
|
+
|
6
|
+
fixture `Viewmode carousel`.page `${BASE_URL}viewmode-cycle.html`;
|
7
|
+
|
8
|
+
test('Clicking `view mode` cycles through view modes', async t => {
|
9
|
+
const { nav } = (new BookReader());
|
10
|
+
|
11
|
+
// viewmode button only appear on mobile devices
|
12
|
+
await t.resizeWindow(400, 800);
|
13
|
+
// Flip forward one
|
14
|
+
await t.pressKey('right');
|
15
|
+
|
16
|
+
// 2up to thumb
|
17
|
+
await t.click(nav.desktop.viewmode);
|
18
|
+
const thumbnailContainer = Selector('.BRmodeThumb');
|
19
|
+
await t.expect(thumbnailContainer.visible).ok();
|
20
|
+
const thumbImages = thumbnailContainer.find('.BRpageview img');
|
21
|
+
await t.expect(thumbImages.count).gt(0);
|
22
|
+
|
23
|
+
// thumb to 1up
|
24
|
+
await t.click(nav.desktop.viewmode);
|
25
|
+
const onePageViewContainer = Selector('br-mode-1up');
|
26
|
+
await t.expect(onePageViewContainer.visible).ok();
|
27
|
+
const onePageImages = onePageViewContainer.find('.BRmode1up .BRpagecontainer');
|
28
|
+
// we usually pre-fetch the page in question & 1 before/after it
|
29
|
+
await t.expect(onePageImages.count).gte(3);
|
30
|
+
|
31
|
+
// 1up to 2up
|
32
|
+
await t.click(nav.desktop.viewmode);
|
33
|
+
const twoPageContainer = Selector('.BRtwopageview');
|
34
|
+
await t.expect(twoPageContainer.visible).ok();
|
35
|
+
const twoPageImages = twoPageContainer.find('img.BRpageimage');
|
36
|
+
await t.expect(twoPageImages.count).gte(2);
|
37
|
+
});
|
@@ -0,0 +1,180 @@
|
|
1
|
+
import {
|
2
|
+
html,
|
3
|
+
elementUpdated,
|
4
|
+
fixtureCleanup,
|
5
|
+
fixtureSync,
|
6
|
+
expect,
|
7
|
+
} from '@open-wc/testing';
|
8
|
+
import sinon from 'sinon';
|
9
|
+
|
10
|
+
import '../../../src/BookNavigator/BookNavigator.js';
|
11
|
+
import BRFullscreenMgr from '../../../src/BookNavigator/br-fullscreen-mgr.js';
|
12
|
+
|
13
|
+
const container = () => {
|
14
|
+
const item = {};
|
15
|
+
return html`
|
16
|
+
<book-navigator
|
17
|
+
.item=${item}
|
18
|
+
.baseHost
|
19
|
+
>
|
20
|
+
<div slot="bookreader">
|
21
|
+
<p class="visible-in-reader">now showing</p>
|
22
|
+
<div>
|
23
|
+
<p class="bunny">foo</p>
|
24
|
+
</
|
25
|
+
`;
|
26
|
+
};
|
27
|
+
|
28
|
+
beforeEach(() => {
|
29
|
+
const body = document.querySelector('body');
|
30
|
+
const brHook = document.createElement('div');
|
31
|
+
brHook.setAttribute('id', 'BookReader');
|
32
|
+
body.appendChild(brHook);
|
33
|
+
});
|
34
|
+
|
35
|
+
afterEach(() => {
|
36
|
+
window.br = null;
|
37
|
+
fixtureCleanup();
|
38
|
+
});
|
39
|
+
|
40
|
+
|
41
|
+
describe('<book-navigator>', () => {
|
42
|
+
describe('first update', () => {
|
43
|
+
it('binds global event listeners', async () => {
|
44
|
+
const el = fixtureSync(container());
|
45
|
+
const spy = sinon.spy(el, 'bindEventListeners');
|
46
|
+
await elementUpdated(el);
|
47
|
+
expect(spy.callCount).to.equal(1);
|
48
|
+
});
|
49
|
+
|
50
|
+
it('emits a BrBookNav:PostInit event', async () => {
|
51
|
+
let initEventFired = false;
|
52
|
+
window.addEventListener('BrBookNav:PostInit', (e) => {
|
53
|
+
initEventFired = true;
|
54
|
+
});
|
55
|
+
const el = fixtureSync(container());
|
56
|
+
const spy = sinon.spy(el, 'emitPostInit');
|
57
|
+
await elementUpdated(el);
|
58
|
+
|
59
|
+
expect(initEventFired).to.be.true;
|
60
|
+
expect(spy.callCount).to.equal(1);
|
61
|
+
});
|
62
|
+
});
|
63
|
+
|
64
|
+
it('handles global event: BookReader:PostInit', async () => {
|
65
|
+
const setTimeoutSpy = sinon.spy(window, 'setTimeout');
|
66
|
+
const brStub = {
|
67
|
+
resize: sinon.fake(),
|
68
|
+
currentIndex: sinon.fake(),
|
69
|
+
jumpToIndex: sinon.fake(),
|
70
|
+
options: { enableMultipleBooks: false }, // for multipleBooks
|
71
|
+
el: '#BookReader'
|
72
|
+
};
|
73
|
+
|
74
|
+
const el = fixtureSync(container());
|
75
|
+
const initializeBookSubmenus = sinon.spy(el, 'initializeBookSubmenus');
|
76
|
+
|
77
|
+
await elementUpdated(el);
|
78
|
+
window.dispatchEvent(new CustomEvent('BookReader:PostInit', {
|
79
|
+
detail: { props: brStub }
|
80
|
+
}));
|
81
|
+
await elementUpdated(el);
|
82
|
+
|
83
|
+
expect(initializeBookSubmenus.callCount).to.equal(1);
|
84
|
+
expect(el.bookreader).to.equal(brStub); // sets bookreader
|
85
|
+
expect(el.bookReaderLoaded).to.be.true; // notes bookreader is loaded
|
86
|
+
expect(el.bookReaderCannotLoad).to.be.false;
|
87
|
+
expect(el.fullscreenMgr).to.an.instanceof(BRFullscreenMgr);
|
88
|
+
expect(el.brResizeObserver).to.an.instanceof(window.ResizeObserver);
|
89
|
+
expect(setTimeoutSpy.callCount).to.equal(1); // resizes at end
|
90
|
+
});
|
91
|
+
|
92
|
+
it('resizes bookreader when side menu toggles', async () => {
|
93
|
+
const el = fixtureSync(container());
|
94
|
+
const brStub = {
|
95
|
+
resize: sinon.fake(),
|
96
|
+
currentIndex: sinon.fake(),
|
97
|
+
jumpToIndex: sinon.fake(),
|
98
|
+
options: { enableMultipleBooks: true },
|
99
|
+
};
|
100
|
+
|
101
|
+
el.bookreader = brStub;
|
102
|
+
await elementUpdated(el);
|
103
|
+
|
104
|
+
el.sideMenuOpen = true;
|
105
|
+
await elementUpdated(el);
|
106
|
+
|
107
|
+
expect(el.bookreader.resize.callCount).to.equal(1);
|
108
|
+
|
109
|
+
el.sideMenuOpen = false;
|
110
|
+
await elementUpdated(el);
|
111
|
+
|
112
|
+
expect(el.bookreader.resize.callCount).to.equal(2);
|
113
|
+
});
|
114
|
+
|
115
|
+
it('does not resize bookreader if animating', async () => {
|
116
|
+
const el = fixtureSync(container());
|
117
|
+
const brStub = {
|
118
|
+
animating: true, // <-- testing for this
|
119
|
+
resize: sinon.fake(),
|
120
|
+
currentIndex: sinon.fake(),
|
121
|
+
jumpToIndex: sinon.fake(),
|
122
|
+
options: { enableMultipleBooks: true }
|
123
|
+
};
|
124
|
+
|
125
|
+
el.bookreader = brStub;
|
126
|
+
await elementUpdated(el);
|
127
|
+
|
128
|
+
el.sideMenuOpen = true;
|
129
|
+
await elementUpdated(el);
|
130
|
+
|
131
|
+
expect(el.bookreader.resize.callCount).to.equal(0);
|
132
|
+
expect(el.bookreader.currentIndex.callCount).to.equal(0);
|
133
|
+
expect(el.bookreader.jumpToIndex.callCount).to.equal(0);
|
134
|
+
});
|
135
|
+
|
136
|
+
describe(`this.updateSideMenu`, () => {
|
137
|
+
it('emits custom event', async () => {
|
138
|
+
const el = fixtureSync(container());
|
139
|
+
const brStub = {
|
140
|
+
resize: sinon.fake(),
|
141
|
+
currentIndex: sinon.fake(),
|
142
|
+
jumpToIndex: sinon.fake(),
|
143
|
+
options: { enableMultipleBooks: true }
|
144
|
+
};
|
145
|
+
el.bookreader = brStub;
|
146
|
+
await elementUpdated(el);
|
147
|
+
|
148
|
+
let initEventFired = false;
|
149
|
+
let eventDetails = {};
|
150
|
+
el.addEventListener('updateSideMenu', (e) => {
|
151
|
+
eventDetails = e.detail;
|
152
|
+
initEventFired = true;
|
153
|
+
});
|
154
|
+
|
155
|
+
el.updateSideMenu('foo', 'open');
|
156
|
+
expect(initEventFired).to.equal(true);
|
157
|
+
expect(eventDetails.menuId).to.equal('foo');
|
158
|
+
expect(eventDetails.action).to.equal('open');
|
159
|
+
});
|
160
|
+
it('does not emit event if missing an arg', async() => {
|
161
|
+
const el = fixtureSync(container());
|
162
|
+
const brStub = {
|
163
|
+
resize: sinon.fake(),
|
164
|
+
currentIndex: sinon.fake(),
|
165
|
+
jumpToIndex: sinon.fake(),
|
166
|
+
options: { enableMultipleBooks: true }
|
167
|
+
};
|
168
|
+
el.bookreader = brStub;
|
169
|
+
await elementUpdated(el);
|
170
|
+
|
171
|
+
let initEventFired = false;
|
172
|
+
el.addEventListener('updateSideMenu', (e) => {
|
173
|
+
initEventFired = true;
|
174
|
+
});
|
175
|
+
|
176
|
+
el.updateSideMenu('', 'open');
|
177
|
+
expect(initEventFired).to.equal(false);
|
178
|
+
});
|
179
|
+
});
|
180
|
+
});
|