Merge pull request #14634 from Snuffleupagus/Driver-run-fetch
Replace XMLHttpRequest usage with the Fetch API in `Driver.run`
This commit is contained in:
commit
7d53a40c91
@ -368,34 +368,32 @@ class Driver {
|
|||||||
this._log(`Harness thinks this browser is ${this.browser}\n`);
|
this._log(`Harness thinks this browser is ${this.browser}\n`);
|
||||||
this._log('Fetching manifest "' + this.manifestFile + '"... ');
|
this._log('Fetching manifest "' + this.manifestFile + '"... ');
|
||||||
|
|
||||||
const r = new XMLHttpRequest();
|
|
||||||
r.open("GET", this.manifestFile, false);
|
|
||||||
r.onreadystatechange = () => {
|
|
||||||
if (r.readyState === 4) {
|
|
||||||
this._log("done\n");
|
|
||||||
this.manifest = JSON.parse(r.responseText);
|
|
||||||
if (this.testFilter?.length || this.xfaOnly) {
|
|
||||||
this.manifest = this.manifest.filter(item => {
|
|
||||||
if (this.testFilter.includes(item.id)) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
if (this.xfaOnly && item.enableXfa) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
});
|
|
||||||
}
|
|
||||||
this.currentTask = 0;
|
|
||||||
this._nextTask();
|
|
||||||
}
|
|
||||||
};
|
|
||||||
if (this.delay > 0) {
|
if (this.delay > 0) {
|
||||||
this._log("\nDelaying for " + this.delay + " ms...\n");
|
this._log("\nDelaying for " + this.delay + " ms...\n");
|
||||||
}
|
}
|
||||||
// When gathering the stats the numbers seem to be more reliable
|
// When gathering the stats the numbers seem to be more reliable
|
||||||
// if the browser is given more time to start.
|
// if the browser is given more time to start.
|
||||||
setTimeout(function () {
|
setTimeout(async () => {
|
||||||
r.send(null);
|
const response = await fetch(this.manifestFile);
|
||||||
|
if (!response.ok) {
|
||||||
|
throw new Error(response.statusText);
|
||||||
|
}
|
||||||
|
this._log("done\n");
|
||||||
|
this.manifest = await response.json();
|
||||||
|
|
||||||
|
if (this.testFilter?.length || this.xfaOnly) {
|
||||||
|
this.manifest = this.manifest.filter(item => {
|
||||||
|
if (this.testFilter.includes(item.id)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
if (this.xfaOnly && item.enableXfa) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
this.currentTask = 0;
|
||||||
|
this._nextTask();
|
||||||
}, this.delay);
|
}, this.delay);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user