Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Add missing pageref attribute to HAR and end-time #306

Closed
wants to merge 2 commits into from

2 participants

@igrigorik

The pageref attribute is required to associate the requests with the appropriate pages. Without it, many tools fail to interpet the data.

Also, added the "onLoad" timer, albeit I'm not 100% sure that the way I have it there is the best way to do it. I tried adding an onLoadFinished callback, but for whatever reason, it just didn't want to fire. Any tips?

Also, I'd love to surface other data such as onDomContentLoaded - is there any way to register this callback? Or, alternatively, is there any way to get access to the performance timing data from phantom? Does the QT port support it?

@ariya
Owner

I've created an issue https://code.google.com/p/phantomjs/wiki/ContributionGuide for discussion (main reason: this GitHub pull request is not searchable at all).

@ariya
Owner

Merged (as squashed). Thanks!

@ariya ariya closed this
@igrigorik

Awesome, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Aug 26, 2012
  1. @igrigorik
  2. @igrigorik

    add onLoad to pageTimings

    igrigorik authored
This page is out of date. Refresh to see the latest.
Showing with 10 additions and 3 deletions.
  1. +4 −1 examples/netsniff.coffee
  2. +6 −2 examples/netsniff.js
View
5 examples/netsniff.coffee
@@ -58,6 +58,7 @@ createHAR = (address, title, startTime, resources) ->
wait: startReply.time - request.time
receive: endReply.time - startReply.time
ssl: -1
+ pageref: address
log:
version: '1.2'
@@ -69,7 +70,8 @@ createHAR = (address, title, startTime, resources) ->
startedDateTime: startTime.toISOString()
id: address
title: title
- pageTimings: {}
+ pageTimings:
+ onLoad: page.endTime - page.startTime
]
entries: entries
@@ -102,6 +104,7 @@ else
if status isnt 'success'
console.log 'FAIL to load the address'
else
+ page.endTime = new Date()
page.title = page.evaluate ->
document.title
View
8 examples/netsniff.js
@@ -61,7 +61,8 @@ function createHAR(address, title, startTime, resources)
wait: startReply.time - request.time,
receive: endReply.time - startReply.time,
ssl: -1
- }
+ },
+ pageref: address
});
});
@@ -77,7 +78,9 @@ function createHAR(address, title, startTime, resources)
startedDateTime: startTime.toISOString(),
id: address,
title: title,
- pageTimings: {}
+ pageTimings: {
+ onLoad: page.endTime - page.startTime
+ }
}],
entries: entries
}
@@ -121,6 +124,7 @@ if (system.args.length === 1) {
if (status !== 'success') {
console.log('FAIL to load the address');
} else {
+ page.endTime = new Date();
page.title = page.evaluate(function () {
return document.title;
});
Something went wrong with that request. Please try again.