Deprecation of chrome.loadtimes()
kav2k opened this issue · 4 comments
The API this extension is built upon is being deprecated starting Chrome 64.
A rewrite is needed to use nextHopProtocol
of Resource Timing Level 2 API.
Chrome 64 is out, meaning that everyone using this extension starts seeing deprecation warnings in the console.
@rauchg I'm gathering Reporting endpoint from ReportingObserver on my service, and I got tons of DeprecationReport caused by this issue.
fixing are welcome !
Let's fix!
Fixing for Deprecation of chrome.loadtimes.
\User Data\Default\Extensions\mpbpobfflnpcgagjijhmgnchggcjblin\1.0.0_0\content.js
`document.addEventListener("DOMContentLoaded", ready);
// send spdy info for current page
function ready(){
chrome.runtime.sendMessage({
spdy: wasFetchedViaSpdy(),
info: npnNegotiatedProtocol() || connectionInfo()
});
chrome.runtime.onMessage.addListener(function (res, sender, sendResponse) {
chrome.runtime.sendMessage({
spdy: wasFetchedViaSpdy(),
info: npnNegotiatedProtocol() || connectionInfo()
});
});
}
function wasFetchedViaSpdy() {
// SPDY is deprecated in favor of HTTP/2, but this implementation returns
// true for HTTP/2 or HTTP2+QUIC/39 as well.
if (window.PerformanceNavigationTiming) {
const ntEntry = performance.getEntriesByType('navigation')[0];
return ['h2', 'hq'].includes(ntEntry.nextHopProtocol);
}
}
function npnNegotiatedProtocol() {
// NPN is deprecated in favor of ALPN, but this implementation returns the
// HTTP/2 or HTTP2+QUIC/39 requests negotiated via ALPN.
if (window.PerformanceNavigationTiming) {
const ntEntry = performance.getEntriesByType('navigation')[0];
return ['h2', 'hq'].includes(ntEntry.nextHopProtocol) ?
ntEntry.nextHopProtocol : 'unknown';
}
}
function connectionInfo() {
if (window.PerformanceNavigationTiming) {
const ntEntry = performance.getEntriesByType('navigation')[0];
return ntEntry.nextHopProtocol;
}
}`