Skip to content

Commit

Permalink
Merge pull request #15 from juliandescottes/null-pageTimings
Browse files Browse the repository at this point in the history
Null page timings
  • Loading branch information
juliandescottes authored Apr 12, 2023
2 parents 6ea3649 + ea22c72 commit 8f8a8bf
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 3 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "ff-test-bidi-har-export",
"version": "0.0.9",
"version": "0.0.10",
"description": "Experimental helper to export HAR files from WebDriverBiDi network events",
"main": "index.js",
"scripts": {
Expand Down
9 changes: 7 additions & 2 deletions src/har-recorder.js
Original file line number Diff line number Diff line change
Expand Up @@ -347,8 +347,13 @@ class HarRecorder {

for (const page of recording.log.pages) {
// Rename timings
page.pageTimings.onContentLoad = page.pageTimings.domContentLoaded * 1;
page.pageTimings.onLoad = page.pageTimings.load * 1;
if (page.pageTimings.domContentLoaded) {
page.pageTimings.onContentLoad = page.pageTimings.domContentLoaded * 1;
}

if (page.pageTimings.load) {
page.pageTimings.onLoad = page.pageTimings.load * 1;
}

// Delete temporary fields
delete page.pageTimings.domContentLoaded;
Expand Down
8 changes: 8 additions & 0 deletions test/har-recorder.initial-page.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,10 @@ test("HarRecorder generates har export with default initial page", () => {
expect(harExport.log.entries.length).toBe(2);
expect(harExport.log.entries[0].pageref).toBe(harExport.log.pages[0].id);
expect(harExport.log.entries[1].pageref).toBe(harExport.log.pages[1].id);
expect(harExport.log.pages[0].pageTimings.onContentLoad).toBeUndefined();
expect(harExport.log.pages[1].pageTimings.onContentLoad).toBeDefined();
expect(harExport.log.pages[0].pageTimings.onLoad).toBeUndefined();
expect(harExport.log.pages[1].pageTimings.onLoad).toBeDefined();
});

test("HarRecorder generates har export with provided initial page", () => {
Expand Down Expand Up @@ -76,4 +80,8 @@ test("HarRecorder generates har export with provided initial page", () => {
expect(harExport.log.entries[0].pageref).toBe(harExport.log.pages[0].id);
expect(harExport.log.pages[0].title).toBe(initialPageUrl);
expect(harExport.log.entries[1].pageref).toBe(harExport.log.pages[1].id);
expect(harExport.log.pages[0].pageTimings.onContentLoad).toBeUndefined();
expect(harExport.log.pages[1].pageTimings.onContentLoad).toBeDefined();
expect(harExport.log.pages[0].pageTimings.onLoad).toBeUndefined();
expect(harExport.log.pages[1].pageTimings.onLoad).toBeDefined();
});
4 changes: 4 additions & 0 deletions test/har-recorder.last-page.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ test("HarRecorder generates har export with default last page", () => {
expect(harExport.log.pages.length).toBe(1);
expect(harExport.log.entries.length).toBe(1);
expect(harExport.log.entries[0].pageref).toBe(harExport.log.pages[0].id);
expect(harExport.log.pages[0].pageTimings.onContentLoad).toBeUndefined();
expect(harExport.log.pages[0].pageTimings.onLoad).toBeUndefined();
});

test("HarRecorder generates har export with provided last page", () => {
Expand All @@ -52,4 +54,6 @@ test("HarRecorder generates har export with provided last page", () => {
expect(harExport.log.entries.length).toBe(1);
expect(harExport.log.entries[0].pageref).toBe(harExport.log.pages[0].id);
expect(harExport.log.pages[0].title).toBe(lastPageUrl);
expect(harExport.log.pages[0].pageTimings.onContentLoad).toBeUndefined();
expect(harExport.log.pages[0].pageTimings.onLoad).toBeUndefined();
});

0 comments on commit 8f8a8bf

Please sign in to comment.