⚠ Archived content — this site is no longer maintained.   Current WebKit documentation is at docs.webkit.org.

Changeset 244576 in webkit


Ignore:
Timestamp:
Apr 23, 2019, 6:20:32 PM (7 years ago)
Author:
Devin Rousso
Message:

Web Inspector: Network: support drag/drop for importing
https://bugs.webkit.org/show_bug.cgi?id=197221

Reviewed by Timothy Hatcher.

  • UserInterface/Views/NetworkTabContentView.js:

(WI.NetworkTabContentView.prototype.async.handleFileDrop): Added.

  • UserInterface/Views/NetworkTableContentView.js:

(WI.NetworkTableContentView.prototype.processHAR): Added.
(WI.NetworkTableContentView.prototype._importHAR):

  • UserInterface/Base/FileUtilities.js:

(WI.FileUtilities.async readText):
Only await if the result is a Promise.

Location:
trunk/Source/WebInspectorUI
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebInspectorUI/ChangeLog

    r244566 r244576  
     12019-04-23  Devin Rousso  <drousso@apple.com>
     2
     3        Web Inspector: Network: support drag/drop for importing
     4        https://bugs.webkit.org/show_bug.cgi?id=197221
     5
     6        Reviewed by Timothy Hatcher.
     7
     8        * UserInterface/Views/NetworkTabContentView.js:
     9        (WI.NetworkTabContentView.prototype.async.handleFileDrop): Added.
     10        * UserInterface/Views/NetworkTableContentView.js:
     11        (WI.NetworkTableContentView.prototype.processHAR): Added.
     12        (WI.NetworkTableContentView.prototype._importHAR):
     13
     14        * UserInterface/Base/FileUtilities.js:
     15        (WI.FileUtilities.async readText):
     16        Only `await` if the result is a `Promise`.
     17
    1182019-04-23  Devin Rousso  <drousso@apple.com>
    219
  • trunk/Source/WebInspectorUI/UserInterface/Base/FileUtilities.js

    r243355 r244576  
    145145
    146146            let promise = callback(result);
    147             if (promise)
     147            if (promise instanceof Promise)
    148148                await promise;
    149149        }
  • trunk/Source/WebInspectorUI/UserInterface/Views/NetworkTabContentView.js

    r228024 r244576  
    8484    }
    8585
     86    async handleFileDrop(files)
     87    {
     88        await WI.FileUtilities.readJSON(files, (result) => this._networkTableContentView.processHAR(result));
     89    }
     90
    8691    // Public
    8792
  • trunk/Source/WebInspectorUI/UserInterface/Views/NetworkTableContentView.js

    r244358 r244576  
    12431243    }
    12441244
     1245    processHAR(result)
     1246    {
     1247        let resources = WI.networkManager.processHAR(result);
     1248        if (!resources)
     1249            return;
     1250
     1251        let importedCollection = this._addCollection();
     1252
     1253        let displayName = WI.UIString("Imported - %s").format(result.filename);
     1254        this._addCollectionPathComponent(importedCollection, displayName, "network-har-icon");
     1255
     1256        this._changeCollection(importedCollection);
     1257
     1258        for (let resource of resources)
     1259            this._insertResourceAndReloadTable(resource);
     1260    }
     1261
    12451262    handleClearShortcut(event)
    12461263    {
     
    21362153    _importHAR()
    21372154    {
    2138         WI.FileUtilities.importJSON((result) => {
    2139             let resources = WI.networkManager.processHAR(result);
    2140             if (!resources)
    2141                 return;
    2142 
    2143             let importedCollection = this._addCollection();
    2144 
    2145             let displayName = WI.UIString("Imported - %s").format(result.filename);
    2146             this._addCollectionPathComponent(importedCollection, displayName, "network-har-icon");
    2147 
    2148             this._changeCollection(importedCollection);
    2149 
    2150             for (let resource of resources)
    2151                 this._insertResourceAndReloadTable(resource);
    2152         });
     2155        WI.FileUtilities.importJSON((result) => this.processHAR(result));
    21532156    }
    21542157
Note: See TracChangeset for help on using the changeset viewer.