WebKit Bugzilla
New
Browse
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
RESOLVED DUPLICATE of
bug 30467
31372
WebInspector: Adds Timer record tests for Timeline agent records
https://bugs.webkit.org/show_bug.cgi?id=31372
Summary
WebInspector: Adds Timer record tests for Timeline agent records
Eric Ayers
Reported
2009-11-11 13:11:08 PST
Adds test of a setTimeout(), a cancelTimeout(), and an interval timer with a cancel too.
Attachments
WebInspector: Adds unit test for Timer records from the Timeline agent.
(14.51 KB, patch)
2009-11-11 14:12 PST
,
Eric Ayers
pfeldman
: review-
Details
Formatted Diff
Diff
View All
Add attachment
proposed patch, testcase, etc.
Eric Ayers
Comment 1
2009-11-11 14:12:34 PST
Created
attachment 43001
[details]
WebInspector: Adds unit test for Timer records from the Timeline agent.
Pavel Feldman
Comment 2
2009-11-11 23:53:15 PST
Comment on
attachment 43001
[details]
WebInspector: Adds unit test for Timer records from the Timeline agent.
> +// Look for the TimerFire event that correlates to the > +// to the <script> tag below.
to the is used twice
> + function analyzeTimerFire(record)
I think I've seen this pattern before. Can we extract something receiving timelineMark and a printcallback or something?
> + var numChildren = record.children ? record.children.length : 0; > + // Look for a MarkTimeline as a direct child. > + for (var i = 0; i < numChildren; ++i) { > + var child = record.children[i]; > + if (child.type === timelineAgentRecordType.MarkTimeline && child.data.message === timelineMark) { > + return record; > + } > + }
This snippet should really be reused.
> +function analyzeTimerFire(record) > +{ > + var numChildren = record.children ? record.children.length : 0; > + for (var i = 0; i < numChildren; ++i) { > + var child = record.children[i]; > + if (child.type === timelineAgentRecordType.MarkTimeline && child.data.message === timelineMark) { > + printTimelineRecordProperties(record); > + return true; > + } > + } > + return false;
ditto
> + // Look for the install that corresponds to the timer fire. > + for (var i = 0 ; i < numRecords; ++i) { > + var record = timelineRecords[i]; > + found = findTimerRecord(timelineAgentRecordType.TimerInstall, record, timerId); > + if (found) > + break;
This pattern is also happening all the time. JavaScript is a dynamic language allowing you to pass functions as parameters, etc. - Implementing forEachRecord would do some code reuse for you. - findRecord(type, goldenData) where golden is a set of properties that should be set in data would also cover lots of stuff. like the snipet above would convert into findRecord(timelineAgentRecordType.MarkTimeline, { message : timelineMark }); or printTimelineRecordProperties(timelineAgentRecordType.MarkTimeline, { message : timelineMark }) to reuse even more. - the approach above would convert findTimerInstall into findRecort(timelineAgentRecordType.TimerInstall, { timerId : timerId }); and should work for eval as well. In other words, please extract some methods. As you create more tests we get more and more code duplication.
Eric Ayers
Comment 3
2009-11-30 06:32:27 PST
*** This bug has been marked as a duplicate of
bug 30467
***
Note
You need to
log in
before you can comment on or make changes to this bug.
Top of Page
Format For Printing
XML
Clone This Bug