Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
data.data.median.firstView.chromeUserTiming.forEach(measure => {
chromeUserTiming[measure.name] = measure.time;
});
data.data.median.firstView.chromeUserTiming = chromeUserTiming;
log.verbose(
'detected chromeUserTiming and restructured them to :%:2j',
chromeUserTiming
);
}
const promises = [];
let har;
promises.push(
getHARData(id, {})
.then(theHar => (har = theHar))
.catch(WPTAPIError, error =>
log.warn(
`Couldn't get HAR for id ${id} ${error.message} (url = ${url})`
)
)
);
const traces = {};
const views = ['firstView'];
if (!wptOptions.firstViewOnly) {
views.push('repeatView');
}
views.forEach(function(view) {
for (let run = 1; run <= wptOptions.runs; run++) {
// The WPT API wrapper mutates the options object, why ohh why?!?!?!
const repeatView = view === 'repeatView';
];
function addCustomMetric(result, filterRegistry) {
const customMetrics = get(result, 'data.median.firstView.custom');
if (customMetrics) {
for (const customMetric of customMetrics) {
filterRegistry.addFilterForType(
'data.median.*.' + customMetric,
'webpagetest.pageSummary'
);
}
}
}
const defaultConfig = {
host: WebPageTest.defaultServer,
location: 'Dulles:Chrome',
connectivity: 'Cable',
runs: 3,
pollResults: 10,
timeout: 600,
includeRepeatView: false,
private: true,
aftRenderingTime: true,
video: true,
timeline: false
};
function isPublicWptHost(address) {
const host = /^(https?:\/\/)?([^/]*)/i.exec(address);
return host && host[2] === urlParser.parse(WebPageTest.defaultServer).host;
}
function isPublicWptHost(address) {
const host = /^(https?:\/\/)?([^/]*)/i.exec(address);
return host && host[2] === urlParser.parse(WebPageTest.defaultServer).host;
}
promises.push(
getWaterfallImage(id, {
run,
chartType: 'connection',
repeatView
})
.then(img =>
storageManager.writeDataForUrl(
img,
'wpt-waterfall-connection' + run + '-' + view + '.png',
url,
'waterfall'
)
)
.catch(WPTAPIError, error =>
log.warn(
`Couldn't get connection waterfall for id ${id}, run ${run}: ${
error.message
} (url = ${url})`
)
)
);
if (wptOptions.timeline) {
promises.push(
getChromeTraceData(id, {
run,
repeatView
})
.then(
trace => (traces['trace-' + run + '-wpt-' + view] = trace)