Identify browsers using the name instead of the path

The other testing code already uses the name of the browser as the
unique identifier, so I don't see a good reason to not use that for
identifying browsers to quit as well. Doing so simplifies the (already
somewhat complex) testing logic and ensures that we can use existing
functionality (such as the `getSession` function) to retrieve sessions.
This commit is contained in:
Tim van der Meij 2020-04-18 16:12:50 +02:00
parent bf416db23d
commit d86720b7dc
No known key found for this signature in database
GPG Key ID: 8C3FD2925A5F2762
5 changed files with 7 additions and 24 deletions

View File

@ -300,7 +300,6 @@ var Driver = (function DriverClosure() {
var parameters = this._getQueryStringParameters(); var parameters = this._getQueryStringParameters();
this.browser = parameters.browser; this.browser = parameters.browser;
this.manifestFile = parameters.manifestFile; this.manifestFile = parameters.manifestFile;
this.appPath = parameters.path;
this.delay = parameters.delay | 0 || 0; this.delay = parameters.delay | 0 || 0;
this.inFlightRequests = 0; this.inFlightRequests = 0;
this.testFilter = parameters.testFilter this.testFilter = parameters.testFilter
@ -340,13 +339,7 @@ var Driver = (function DriverClosure() {
); );
}; };
this._info("User agent: " + navigator.userAgent); this._info("User agent: " + navigator.userAgent);
this._log( this._log(`Harness thinks this browser is ${this.browser}\n`);
'Harness thinks this browser is "' +
this.browser +
'" with path "' +
this.appPath +
'"\n'
);
this._log('Fetching manifest "' + this.manifestFile + '"... '); this._log('Fetching manifest "' + this.manifestFile + '"... ');
var r = new XMLHttpRequest(); var r = new XMLHttpRequest();
@ -679,7 +672,7 @@ var Driver = (function DriverClosure() {
// Send the quit request // Send the quit request
var r = new XMLHttpRequest(); var r = new XMLHttpRequest();
r.open("POST", "/tellMeToQuit?path=" + escape(this.appPath), false); r.open("POST", `/tellMeToQuit?browser=${escape(this.browser)}`, false);
r.onreadystatechange = function (e) { r.onreadystatechange = function (e) {
if (r.readyState === 4) { if (r.readyState === 4) {
window.close(); window.close();

View File

@ -119,10 +119,7 @@ function initializePDFJS(callback) {
env.addReporter(htmlReporter); env.addReporter(htmlReporter);
if (queryString.getParam("browser")) { if (queryString.getParam("browser")) {
var testReporter = new TestReporter( var testReporter = new TestReporter(queryString.getParam("browser"));
queryString.getParam("browser"),
queryString.getParam("path")
);
env.addReporter(testReporter); env.addReporter(testReporter);
} }

View File

@ -617,11 +617,7 @@ function refTestPostHandler(req, res) {
var session; var session;
if (pathname === "/tellMeToQuit") { if (pathname === "/tellMeToQuit") {
// finding by path session = getSession(parsedUrl.query.browser);
var browserPath = parsedUrl.query.path;
session = sessions.filter(function (curSession) {
return curSession.config.path === browserPath;
})[0];
monitorBrowserTimeout(session, null); monitorBrowserTimeout(session, null);
closeSession(session.name); closeSession(session.name);
return; return;

View File

@ -175,10 +175,7 @@ function initializePDFJS(callback) {
env.addReporter(htmlReporter); env.addReporter(htmlReporter);
if (queryString.getParam("browser")) { if (queryString.getParam("browser")) {
var testReporter = new TestReporter( var testReporter = new TestReporter(queryString.getParam("browser"));
queryString.getParam("browser"),
queryString.getParam("path")
);
env.addReporter(testReporter); env.addReporter(testReporter);
} }

View File

@ -1,7 +1,7 @@
"use strict"; "use strict";
// eslint-disable-next-line no-unused-vars // eslint-disable-next-line no-unused-vars
var TestReporter = function (browser, appPath) { var TestReporter = function (browser) {
function send(action, json, cb) { function send(action, json, cb) {
var r = new XMLHttpRequest(); var r = new XMLHttpRequest();
// (The POST URI is ignored atm.) // (The POST URI is ignored atm.)
@ -39,7 +39,7 @@ var TestReporter = function (browser, appPath) {
} }
function sendQuitRequest() { function sendQuitRequest() {
send("/tellMeToQuit?path=" + escape(appPath), {}); send(`/tellMeToQuit?browser=${escape(browser)}`, {});
} }
this.now = function () { this.now = function () {