Skip to content

Commit

Permalink
Fix for Chrome 43
Browse files Browse the repository at this point in the history
  • Loading branch information
alex-vv committed May 17, 2015
1 parent a309919 commit f92891f
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/manifest.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "Page load time",
"version": "1.2.2",
"version": "1.2.3",
"manifest_version": 2,
"description": "Displays page load time in the toolbar",
"background": {
Expand Down
12 changes: 10 additions & 2 deletions src/timer.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,16 @@
if (t.loadEventEnd > 0) {
// we have only 4 chars in our disposal including decimal point
var time = String(((t.loadEventEnd - start) / 1000).toPrecision(3)).substring(0, 4);
var roe = chrome.runtime && chrome.runtime.sendMessage ? 'runtime' : 'extension';
chrome[roe].sendMessage({time: time, timing: t});
var roe = chrome.runtime && chrome.runtime.sendMessage ? 'runtime' : 'extension';

// since Chrome 43 JSON.stringify() doesn't work for PerformanceTiming
// https://code.google.com/p/chromium/issues/detail?id=467366
// need to manually copy properties via for .. in loop
var timing = {};
for (p in t) {
timing[p] = t[p];
}
chrome[roe].sendMessage({time: time, timing: timing});
}
}, 0);
}
Expand Down

0 comments on commit f92891f

Please sign in to comment.