Bug 192959 - Web Inspector: Charles Proxy errors opening har files exported from Safari (invalid startedDateTime)
Summary: Web Inspector: Charles Proxy errors opening har files exported from Safari (i...
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: Web Inspector (show other bugs)
Version: WebKit Nightly Build
Hardware: All All
: P2 Normal
Assignee: Joseph Pecoraro
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2018-12-20 16:01 PST by Joseph Pecoraro
Modified: 2018-12-20 16:58 PST (History)
6 users (show)

See Also:


Attachments
[PATCH] Proposed Fix (3.90 KB, patch)
2018-12-20 16:11 PST, Joseph Pecoraro
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Joseph Pecoraro 2018-12-20 16:01:51 PST
Charles Proxy errors opening har files exported from Safari (invalid startedDateTime)

Steps to Reproduce:
1. Open apple.com
2. Open inspector after page load
3. Export a HAR from Network Tab (lacking resource load data, just listing existing resource)
4. Open HAR in Charles
  => ‘JsonParse: Invalid format: “”’

Note:
• This is due to `"startedDateTime" = ""` in the HAR content
• `startedDateTime` is non-optional in entries and pages: http://www.softwareishard.com/blog/har-12-spec/

Proposal:
We should not allow exporting a HAR without full load data. So disallow HAR export when just opening the inspector for a page but allowing it on reload / navigation once we have main resource content.
Comment 1 Joseph Pecoraro 2018-12-20 16:02:01 PST
<rdar://problem/46863411>
Comment 2 Joseph Pecoraro 2018-12-20 16:11:42 PST
Created attachment 357893 [details]
[PATCH] Proposed Fix
Comment 3 BJ Burg 2018-12-20 16:29:11 PST
Comment on attachment 357893 [details]
[PATCH] Proposed Fix

r=me

Is there a way to test this? And, we probably should update documentation somewhere to explain this restriction.
Comment 4 Devin Rousso 2018-12-20 16:32:03 PST
Comment on attachment 357893 [details]
[PATCH] Proposed Fix

View in context: https://bugs.webkit.org/attachment.cgi?id=357893&action=review

> Source/WebInspectorUI/UserInterface/Views/NetworkTableContentView.js:1167
> +        let mainResource = mainFrame.mainResource;

Considering that the HAR is built based on the filtered resources in the table, is this check necessary?  Do we allow an export without the main resource?

> Source/WebInspectorUI/UserInterface/Views/NetworkTableContentView.js:1168
> +        if (!mainResource)

Aside: is it ever possible for the `mainFrame` to not have a `mainResource`?

> Source/WebInspectorUI/UserInterface/Views/NetworkTableContentView.js:1174
> +        if (!this._HARResources().length)

NIT: I know that this isn't part of this patch, but shouldn't this be named `_harResouces`?
Comment 5 Joseph Pecoraro 2018-12-20 16:36:24 PST
(In reply to Brian Burg from comment #3)
> Comment on attachment 357893 [details]
> [PATCH] Proposed Fix
> 
> r=me
> 
> Is there a way to test this? And, we probably should update documentation
> somewhere to explain this restriction.

Existing HAR tests passed. The rest is primarily a UI restriction.


(In reply to Devin Rousso from comment #4)
> Comment on attachment 357893 [details]
> [PATCH] Proposed Fix
> 
> View in context:
> https://bugs.webkit.org/attachment.cgi?id=357893&action=review
> 
> > Source/WebInspectorUI/UserInterface/Views/NetworkTableContentView.js:1167
> > +        let mainResource = mainFrame.mainResource;
> 
> Considering that the HAR is built based on the filtered resources in the
> table, is this check necessary?  Do we allow an export without the main
> resource?

We can export a subset, but the HAR itself will need top level info.

> > Source/WebInspectorUI/UserInterface/Views/NetworkTableContentView.js:1168
> > +        if (!mainResource)
> 
> Aside: is it ever possible for the `mainFrame` to not have a `mainResource`?

Probably not, but might as well check. I don't know about cases like ITMLKit.

> > Source/WebInspectorUI/UserInterface/Views/NetworkTableContentView.js:1174
> > +        if (!this._HARResources().length)
> 
> NIT: I know that this isn't part of this patch, but shouldn't this be named
> `_harResouces`?

Either works.
Comment 6 WebKit Commit Bot 2018-12-20 16:58:53 PST
Comment on attachment 357893 [details]
[PATCH] Proposed Fix

Clearing flags on attachment: 357893

Committed r239478: <https://trac.webkit.org/changeset/239478>
Comment 7 WebKit Commit Bot 2018-12-20 16:58:54 PST
All reviewed patches have been landed.  Closing bug.