Bug 121382 - Web Inspector: TypeError when updating ResourceTreeElement created in strange order
Summary: Web Inspector: TypeError when updating ResourceTreeElement created in strange...
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: Web Inspector (show other bugs)
Version: 528+ (Nightly build)
Hardware: All All
: P2 Normal
Assignee: Nobody
URL: http://www.pixastic.com/labs/digg_att...
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2013-09-15 03:17 PDT by Brian Burg
Modified: 2013-09-16 13:23 PDT (History)
5 users (show)

See Also:


Attachments
trivial fix for missing instanceof check (2.36 KB, patch)
2013-09-15 03:17 PDT, Brian Burg
no flags Details | Formatted Diff | Diff
[PATCH] Brian's fix with ChangeLog (2.67 KB, patch)
2013-09-16 11:41 PDT, 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 Brian Burg 2013-09-15 03:17:29 PDT
Created attachment 211698 [details]
trivial fix for missing instanceof check

Repro:

Go to any web page with the inspector open. Then, navigate to http://www.pixastic.com/labs/digg_attack/. The inspector will encounter a TypeError.

[Error] TypeError: undefined is not a function (evaluating 'this.updateStatusForMainFrame()')
	_updateStatus (ResourceTreeElement.js, line 188)
	dispatch (Object.js, line 180)
	dispatchEventToListeners (Object.js, line 187)
	markAsFinished (Resource.js, line 593)
	resourceRequestDidFinishLoading (FrameResourceManager.js, line 320)
	loadingFinished (NetworkObserver.js, line 58)
	dispatch (InspectorBackend.js, line 262)
	dispatchNextQueuedMessageFromBackend (Main.js, line 298)
	(anonymous function)

Analysis:

It appears this happens only on navigating to this page, not on reloading it. When reloaded, a ResourceTreeElement for the main frame resource is created (triggered by adding breakpoints, IIRC), then a FrameTreeElement for the main frame resource is created later. In the navigation case, the instantiation order is reversed for some reason; since the main frame is already established by this later time, the guard inside ResourceTreeElement._updateStatus succeeds despite the constructor being incorrect.

Fix:

I was able to avoid this error by adding an instanceof check to the guard. A trivial patch (with some previously missed code cleanup) is attached; I'm busy this weekend and won't have time to update my integration checkout, rebase, make changelog, etc until later this week. Feel free to commit it, or not.
Comment 1 Radar WebKit Bug Importer 2013-09-15 03:17:42 PDT
<rdar://problem/14994748>
Comment 2 Timothy Hatcher 2013-09-15 11:48:41 PDT
Looks like stuff Joe was working on recently for the download button.
Comment 3 Joseph Pecoraro 2013-09-16 11:13:57 PDT
Patch looks good. I'm going to try to reproduce, confirm the patch works, and get it reviewed. Thanks for finding this!
Comment 4 Joseph Pecoraro 2013-09-16 11:38:29 PDT
(In reply to comment #3)
> Patch looks good. I'm going to try to reproduce, confirm the patch works, and get it reviewed. Thanks for finding this!

I wasn't able to reproduce the original uncaught exception. But the patch is good regardless.
Comment 5 Joseph Pecoraro 2013-09-16 11:41:26 PDT
Created attachment 211811 [details]
[PATCH] Brian's fix with ChangeLog
Comment 6 Darin Adler 2013-09-16 11:57:38 PDT
Comment on attachment 211811 [details]
[PATCH] Brian's fix with ChangeLog

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

> Source/WebInspectorUI/UserInterface/ResourceTreeElement.js:-175
> -    _updateStatusWithMainFrameButtons: function()
> -    {
> -        if (this._reloadButton) {
> -            this.status = this._reloadButton;
> -            return;
> -        }
> -
> -        if (!this._loadingMainFrameButtons) {
> -            this._loadingMainFrameButtons = true;
> -            var tooltip = WebInspector.UIString("Reload page (%s)\nReload ignoring cache (%s)").format(WebInspector._reloadPageKeyboardShortcut.displayName, WebInspector._reloadPageIgnoringCacheKeyboardShortcut.displayName);
> -            wrappedSVGDocument("Images/Reload.svg", "reload-button", tooltip, function(svgDocument) {
> -                this._reloadButton = svgDocument;
> -                this._reloadButton.addEventListener("click", this._reloadPageClicked);
> -                this.status = this._reloadButton;
> -                delete this._loadingMainFrameButtons;
> -            }.bind(this));
> -        }
> -    },

Change log doesn’t mentioned this deletion.
Comment 7 Joseph Pecoraro 2013-09-16 12:02:58 PDT
(In reply to comment #6)
> (From update of attachment 211811 [details])
> View in context: https://bugs.webkit.org/attachment.cgi?id=211811&action=review
> 
> > Source/WebInspectorUI/UserInterface/ResourceTreeElement.js:-175
> > -    _updateStatusWithMainFrameButtons: function()
> > -    {
> > -        if (this._reloadButton) {
> > -            this.status = this._reloadButton;
> > -            return;
> > -        }
> > -
> > -        if (!this._loadingMainFrameButtons) {
> > -            this._loadingMainFrameButtons = true;
> > -            var tooltip = WebInspector.UIString("Reload page (%s)\nReload ignoring cache (%s)").format(WebInspector._reloadPageKeyboardShortcut.displayName, WebInspector._reloadPageIgnoringCacheKeyboardShortcut.displayName);
> > -            wrappedSVGDocument("Images/Reload.svg", "reload-button", tooltip, function(svgDocument) {
> > -                this._reloadButton = svgDocument;
> > -                this._reloadButton.addEventListener("click", this._reloadPageClicked);
> > -                this.status = this._reloadButton;
> > -                delete this._loadingMainFrameButtons;
> > -            }.bind(this));
> > -        }
> > -    },
> 
> Change log doesn’t mentioned this deletion.

I guess that is a prepare-ChangeLog issue. This function is unused code that should have been removed when we switched to "updateStatusForMainFrame".
Comment 8 Timothy Hatcher 2013-09-16 12:59:44 PDT
Comment on attachment 211811 [details]
[PATCH] Brian's fix with ChangeLog

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

>>> Source/WebInspectorUI/UserInterface/ResourceTreeElement.js:-175
>>> -    },
>> 
>> Change log doesn’t mentioned this deletion.
> 
> I guess that is a prepare-ChangeLog issue. This function is unused code that should have been removed when we switched to "updateStatusForMainFrame".

prepare-ChangeLog has never called out removed functions. That is something you need to manual do.
Comment 9 WebKit Commit Bot 2013-09-16 13:23:11 PDT
Comment on attachment 211811 [details]
[PATCH] Brian's fix with ChangeLog

Clearing flags on attachment: 211811

Committed r155896: <http://trac.webkit.org/changeset/155896>
Comment 10 WebKit Commit Bot 2013-09-16 13:23:13 PDT
All reviewed patches have been landed.  Closing bug.