Bug 201046 - Web Inspector: provide a way to view XML/HTML/SVG resource responses as a DOM tree
Summary: Web Inspector: provide a way to view XML/HTML/SVG resource responses as a DOM...
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: Devin Rousso
URL:
Keywords: InRadar
Depends on:
Blocks: 203836
  Show dependency treegraph
 
Reported: 2019-08-22 11:48 PDT by Devin Rousso
Modified: 2019-11-04 19:20 PST (History)
5 users (show)

See Also:


Attachments
Patch (83.22 KB, patch)
2019-08-22 16:10 PDT, Devin Rousso
no flags Details | Formatted Diff | Diff
[Image] After Patch is applied (251.66 KB, image/png)
2019-08-22 16:11 PDT, Devin Rousso
no flags Details
Patch (86.37 KB, patch)
2019-09-03 18:41 PDT, Devin Rousso
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Devin Rousso 2019-08-22 11:48:14 PDT
Similar to how JSON can be viewed as an object (<https://webkit.org/b/122898>), we should have a DOM tree view for XML/HTML/SVG responses.
Comment 1 Devin Rousso 2019-08-22 12:02:28 PDT
<rdar://problem/54446087>
Comment 2 Devin Rousso 2019-08-22 16:10:59 PDT
Created attachment 377065 [details]
Patch
Comment 3 Devin Rousso 2019-08-22 16:11:13 PDT
Created attachment 377066 [details]
[Image] After Patch is applied
Comment 4 Joseph Pecoraro 2019-09-03 16:27:02 PDT
Comment on attachment 377065 [details]
Patch

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

r=me

> Source/WebInspectorUI/UserInterface/Views/LocalDOMContentView.js:45
> +        let content = this._content.replace(/`/g, "\\`");
> +        let mimeType = this._mimeType.replace(/"/g, "\\\"");
> +        return `(new DOMParser).parseFromString(\`${content}\`, "${mimeType}")`;

Can these just be `JSON.stringify(x)` calls?

    return `(new DOMParser).parseFromString(${JSON.stringify(content)}), ${JSON.stringify(mimeType)})`;

> Source/WebInspectorUI/UserInterface/Views/LocalDOMContentView.js:56
> +                treeOutline[WI.DOMTreeOutline.usingLocalDOMNodeSymbol] = true;

Why not make this an API method instead of a symbol property?

> Source/WebInspectorUI/UserInterface/Views/LocalRemoteObjectContentView.js:59
> +        RuntimeAgent.evaluate.invoke(options, (error, result, wasThrown) => {

I wonder if we should give this a `target` now?

I think this could be any target, in which case we could just use `WI.mainTarget`.

> Source/WebInspectorUI/UserInterface/Views/ResourceClusterContentView.js:408
> +        case "text/xml":
> +        case "application/xml":
> +        case "application/xhtml+xml":
> +        case "image/svg+xml":

It is very common for arbitrary mime types to have a "+xml" suffix, so we should probably do:

    if (mimeType.endsWith("/xml") || mimeType.endsWith("+xml"))
        ...;

> Source/WebInspectorUI/UserInterface/Views/ResourceClusterContentView.js:412
> +            } catch {}

Style: We normally have a space in here: `catch { }`.

> Source/WebInspectorUI/UserInterface/Views/ResourceClusterContentView.js:497
> +    Request: "request",
> +    RequestJSON: "request-json",

Why not Request DOM? I'm sure someone out there still sends XML to their server!
Comment 5 Devin Rousso 2019-09-03 18:34:20 PDT
Comment on attachment 377065 [details]
Patch

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

>> Source/WebInspectorUI/UserInterface/Views/LocalDOMContentView.js:45
>> +        return `(new DOMParser).parseFromString(\`${content}\`, "${mimeType}")`;
> 
> Can these just be `JSON.stringify(x)` calls?
> 
>     return `(new DOMParser).parseFromString(${JSON.stringify(content)}), ${JSON.stringify(mimeType)})`;

Doh!

>> Source/WebInspectorUI/UserInterface/Views/ResourceClusterContentView.js:408
>> +        case "image/svg+xml":
> 
> It is very common for arbitrary mime types to have a "+xml" suffix, so we should probably do:
> 
>     if (mimeType.endsWith("/xml") || mimeType.endsWith("+xml"))
>         ...;

Ooooo, that's true!

>> Source/WebInspectorUI/UserInterface/Views/ResourceClusterContentView.js:497
>> +    RequestJSON: "request-json",
> 
> Why not Request DOM? I'm sure someone out there still sends XML to their server!

Why not indeed!  I'll add it :D
Comment 6 Devin Rousso 2019-09-03 18:41:17 PDT
Created attachment 377946 [details]
Patch
Comment 7 WebKit Commit Bot 2019-09-03 19:57:33 PDT
Comment on attachment 377946 [details]
Patch

Clearing flags on attachment: 377946

Committed r249451: <https://trac.webkit.org/changeset/249451>
Comment 8 WebKit Commit Bot 2019-09-03 19:57:34 PDT
All reviewed patches have been landed.  Closing bug.