Skip to content

Commit

Permalink
Hack to make it possible to measure the same URL multiple times #804 (#…
Browse files Browse the repository at this point in the history
…805)

This is a hack to make sure you can test the same URLs within the same
script. There are users that logs in and logs out the user on the
same URL and that breakes since we use the URL to create all the files
for that URL.

This hack adds a incremental query parameter to the URL.
  • Loading branch information
soulgalore authored Mar 23, 2019
1 parent 65ffa84 commit cf4d2b2
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions lib/core/engine/command/measure.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ class Measure {
this.numberOfMeasuredPages = 0;
this.numberOfVisitedPages = 0;
this.areWeMeasuring = false;
this.testedURLs = {};
}

// Have a concistent way of starting the video
Expand Down Expand Up @@ -191,6 +192,20 @@ class Measure {
}
}

if (this.testedURLs[url]) {
log.info(
'%s has been tested before within the same run, it will get an extra query parameter named browsertime_run. Make sure to use alias to keep track of the URLs',
url
);
this.testedURLs[url] = this.testedURLs[url] + 1;
if (url.indexOf('?') > -1) {
url = url + '&browsertime_run=' + this.testedURLs[url];
} else {
url = url + '?browsertime_run=' + this.testedURLs[url];
}
} else {
this.testedURLs[url] = 1;
}
this.result[this.numberOfMeasuredPages].url = url;

const syncScripts = this.scriptsByCategory
Expand Down

0 comments on commit cf4d2b2

Please sign in to comment.