Skip to content
This repository

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

Closed
wants to merge 2 commits into from

2 participants

Ilya Grigorik Ariya Hidayat
Ilya Grigorik

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 Hidayat
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 Hidayat
Owner

Merged (as squashed). Thanks!

Ariya Hidayat ariya closed this
Ilya Grigorik

Awesome, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
This page is out of date. Refresh to see the latest.
5  examples/netsniff.coffee
@@ -58,6 +58,7 @@ createHAR = (address, title, startTime, resources) ->
58 58
                 wait: startReply.time - request.time
59 59
                 receive: endReply.time - startReply.time
60 60
                 ssl: -1
  61
+            pageref: address
61 62
 
62 63
     log:
63 64
         version: '1.2'
@@ -69,7 +70,8 @@ createHAR = (address, title, startTime, resources) ->
69 70
             startedDateTime: startTime.toISOString()
70 71
             id: address
71 72
             title: title
72  
-            pageTimings: {}
  73
+            pageTimings:
  74
+                onLoad: page.endTime - page.startTime
73 75
         ]
74 76
         entries: entries
75 77
 
@@ -102,6 +104,7 @@ else
102 104
         if status isnt 'success'
103 105
             console.log 'FAIL to load the address'
104 106
         else
  107
+            page.endTime = new Date()
105 108
             page.title = page.evaluate ->
106 109
                 document.title
107 110
 
8  examples/netsniff.js
@@ -61,7 +61,8 @@ function createHAR(address, title, startTime, resources)
61 61
                 wait: startReply.time - request.time,
62 62
                 receive: endReply.time - startReply.time,
63 63
                 ssl: -1
64  
-            }
  64
+            },
  65
+            pageref: address
65 66
         });
66 67
     });
67 68
 
@@ -77,7 +78,9 @@ function createHAR(address, title, startTime, resources)
77 78
                 startedDateTime: startTime.toISOString(),
78 79
                 id: address,
79 80
                 title: title,
80  
-                pageTimings: {}
  81
+                pageTimings: {
  82
+                    onLoad: page.endTime - page.startTime
  83
+                }
81 84
             }],
82 85
             entries: entries
83 86
         }
@@ -121,6 +124,7 @@ if (system.args.length === 1) {
121 124
         if (status !== 'success') {
122 125
             console.log('FAIL to load the address');
123 126
         } else {
  127
+            page.endTime = new Date();
124 128
             page.title = page.evaluate(function () {
125 129
                 return document.title;
126 130
             });
Commit_comment_tip

Tip: You can add notes to lines in a file. Hover to the left of a line to make a note

Something went wrong with that request. Please try again.