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

View File

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

View File

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

View File

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

View File

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