Merge pull request #14581 from Snuffleupagus/Driver-parseQueryString

Use the (viewer) `parseQueryString` helper function in the reference tests
This commit is contained in:
Tim van der Meij 2022-02-19 14:47:37 +01:00 committed by GitHub
commit 964601ba39
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 15 deletions

View File

@ -26,7 +26,7 @@ const {
shadow, shadow,
XfaLayer, XfaLayer,
} = pdfjsLib; } = pdfjsLib;
const { SimpleLinkService } = pdfjsViewer; const { parseQueryString, SimpleLinkService } = pdfjsViewer;
const WAITING_TIME = 100; // ms const WAITING_TIME = 100; // ms
const CMAP_URL = "/build/generic/web/cmaps/"; const CMAP_URL = "/build/generic/web/cmaps/";
@ -332,25 +332,18 @@ class Driver {
this.end = options.end; this.end = options.end;
// Set parameters from the query string // Set parameters from the query string
const parameters = this._getQueryStringParameters(); const params = parseQueryString(window.location.search.substring(1));
this.browser = parameters.browser; this.browser = params.get("browser");
this.manifestFile = parameters.manifestFile; this.manifestFile = params.get("manifestfile");
this.delay = parameters.delay | 0 || 0; this.delay = params.get("delay") | 0;
this.inFlightRequests = 0; this.inFlightRequests = 0;
this.testFilter = parameters.testFilter this.testFilter = JSON.parse(params.get("testfilter") || "[]");
? JSON.parse(parameters.testFilter) this.xfaOnly = params.get("xfaonly") === "true";
: [];
this.xfaOnly = parameters.xfaOnly === "true";
// Create a working canvas // Create a working canvas
this.canvas = document.createElement("canvas"); this.canvas = document.createElement("canvas");
} }
_getQueryStringParameters() {
const queryString = window.location.search.substring(1);
return Object.fromEntries(new URLSearchParams(queryString).entries());
}
run() { run() {
window.onerror = (message, source, line, column, error) => { window.onerror = (message, source, line, column, error) => {
this._info( this._info(

View File

@ -24,6 +24,7 @@ import {
PDFLinkService, PDFLinkService,
SimpleLinkService, SimpleLinkService,
} from "./pdf_link_service.js"; } from "./pdf_link_service.js";
import { parseQueryString, ProgressBar } from "./ui_utils.js";
import { PDFSinglePageViewer, PDFViewer } from "./pdf_viewer.js"; import { PDFSinglePageViewer, PDFViewer } from "./pdf_viewer.js";
import { AnnotationLayerBuilder } from "./annotation_layer_builder.js"; import { AnnotationLayerBuilder } from "./annotation_layer_builder.js";
import { DownloadManager } from "./download_manager.js"; import { DownloadManager } from "./download_manager.js";
@ -34,7 +35,6 @@ import { PDFFindController } from "./pdf_find_controller.js";
import { PDFHistory } from "./pdf_history.js"; import { PDFHistory } from "./pdf_history.js";
import { PDFPageView } from "./pdf_page_view.js"; import { PDFPageView } from "./pdf_page_view.js";
import { PDFScriptingManager } from "./pdf_scripting_manager.js"; import { PDFScriptingManager } from "./pdf_scripting_manager.js";
import { ProgressBar } from "./ui_utils.js";
import { StructTreeLayerBuilder } from "./struct_tree_layer_builder.js"; import { StructTreeLayerBuilder } from "./struct_tree_layer_builder.js";
import { TextLayerBuilder } from "./text_layer_builder.js"; import { TextLayerBuilder } from "./text_layer_builder.js";
import { XfaLayerBuilder } from "./xfa_layer_builder.js"; import { XfaLayerBuilder } from "./xfa_layer_builder.js";
@ -55,6 +55,7 @@ export {
GenericL10n, GenericL10n,
LinkTarget, LinkTarget,
NullL10n, NullL10n,
parseQueryString,
PDFFindController, PDFFindController,
PDFHistory, PDFHistory,
PDFLinkService, PDFLinkService,