an empirical study of client-side javascript bugs

26
An Empirical Study of Client- Side JavaScript Bugs Frolin S. Ocariza, Jr. Kartik Bajaj, Karthik Pattabiraman, Ali Mesbah University of British Columbia

Upload: rene

Post on 23-Feb-2016

64 views

Category:

Documents


0 download

DESCRIPTION

An Empirical Study of Client-Side JavaScript Bugs. University of British Columbia. Frolin S. Ocariza, Jr. Kartik Bajaj, Karthik Pattabiraman , Ali Mesbah. Why Study Client-Side JavaScript (JS) Bugs?. Other uses of JS: widgets, servers, hybrid mobile apps JavaScript can be confusing! - PowerPoint PPT Presentation

TRANSCRIPT

Page 1: An Empirical Study of Client-Side JavaScript Bugs

An Empirical Study of Client-Side JavaScript Bugs

Frolin S. Ocariza, Jr.Kartik Bajaj, Karthik Pattabiraman, Ali Mesbah

University of British Columbia

Page 2: An Empirical Study of Client-Side JavaScript Bugs

Why Study Client-Side JavaScript (JS) Bugs? Other uses of JS: widgets, servers, hybrid

mobile apps

JavaScript can be confusing! Weak typing, Asynchronous/Event-driven, eval()

2

# ofFaults

Page 3: An Empirical Study of Client-Side JavaScript Bugs

Goal of This Study

3

Goal #1: Discover the causes of JavaScript faults

Goal #2: Discover the consequences of JavaScript faults

- Better tests and analysis tools for client-side JavaScript

- Do these faults have any impact?

Page 4: An Empirical Study of Client-Side JavaScript Bugs

JavaScript Bug Sequence: Some Terminology Programmer makes a

mistakeERROR

Erroneous value gets usedFAULT

Code terminates or generates wrong outputFAILURE

4

x = {“foo”: “some value”};

key = “moo”;

y = x[key];

...

...

z = y.length;

EXCEPTION!

EVALUATES TO UNDEFINED

MISTAKE!

Page 5: An Empirical Study of Client-Side JavaScript Bugs

What We Analyze: Bug Reports Main item of analysis

Bug reports contain detailed information from patches, developer comments, etc.

Console messages don’t directly tell us what the causes and consequences are of the fault

5

Page 6: An Empirical Study of Client-Side JavaScript Bugs

Experimental Objects

6

Eight JavaScript Web Applications

Four JavaScript Libraries

Reports per repository:min{30, NumJSReports}

Total Reports Analyzed:317

Page 7: An Empirical Study of Client-Side JavaScript Bugs

Bug Report Collection

7

Bug/Defect?

Bug Report

DISCARDNO

Fixed? YES

NO

JS Fault

?

YES

NO

Create XML file for bug

report YES

Page 8: An Empirical Study of Client-Side JavaScript Bugs

8

Initial Description

DeveloperComments

Classifications

Page 9: An Empirical Study of Client-Side JavaScript Bugs

Research Questions1. What are the types of faults that exist

among reported bugs, and how prevalent are they?

2. What impact do these JavaScript faults have on the web application?

3. What are the root causes of these JavaScript faults?

4. How long does it take programmers to fix JavaScript faults?

9

Page 10: An Empirical Study of Client-Side JavaScript Bugs

Research Questions1. What are the types of faults that exist

among reported bugs, and how prevalent are they?

2. What impact do these JavaScript faults have on the web application?

3. What are the root causes of these JavaScript faults?

4. How long does it take programmers to fix JavaScript faults?

10

Page 11: An Empirical Study of Client-Side JavaScript Bugs

RQ1 – Fault Categories: Results

11

Incorrect Method Parameter: Error propagated into parameter of native JS method

88% of these native methods are part of the DOM API

Page 12: An Empirical Study of Client-Side JavaScript Bugs

JavaScript DOM API

12

html

body head

scripttable p

Text: “Hello world”

table

tr tr

Page 13: An Empirical Study of Client-Side JavaScript Bugs

JavaScript DOM API

13

table

id: foo

JavaScript code:

DOM:

var x = document.getElementById(“foo”);

No longer existsReturns null

Dynamically modified

id: bar

Page 14: An Empirical Study of Client-Side JavaScript Bugs

RQ1 – Fault Categories: Results

14

DOM-Related Faults

What programmer expects to be in the DOM vs what is actually in the DOM

65% of all JavaScript faults

Page 15: An Empirical Study of Client-Side JavaScript Bugs

Research Questions1. What are the types of faults that exist

among reported bugs, and how prevalent are they?

2. What impact do these JavaScript faults have on the web application?

3. What are the root causes of these JavaScript faults?

4. How long does it take programmers to fix JavaScript faults?

15

Page 16: An Empirical Study of Client-Side JavaScript Bugs

RQ2 – Impact: Results Impact Types

Type 1 (lowest impact), Type 5 (highest impact)

16

Type

1Ty

pe 2Ty

pe 3Ty

pe 4Ty

pe 5

0

20

40

60

80

100

120

140

All FaultsDOM-Related Faults Only

Impact Type

Num

ber

of B

ug

Repo

rts

80% of highest impact faults are DOM-related

Page 17: An Empirical Study of Client-Side JavaScript Bugs

High-Impact Bugs Data loss: Save functionality not working,

mail not sent Occurred in: Joomla, WordPress, Drupal,

Roundcube, Prototype Browser hangs: typically browser-specific

Occurred in: Roundcube, Prototype Information leakage: One case where

server code accidentally gets displayed Occurred in: TYPO3

Unusable application: Login functionality not working Occurred in: Moodle, Drupal, WikiMedia, jQuery,

Ember.js17

Page 18: An Empirical Study of Client-Side JavaScript Bugs

Research Questions1. What are the types of faults that exist

among reported bugs, and how prevalent are they?

2. What impact do these JavaScript faults have on the web application?

3. What are the root causes of these JavaScript faults?

4. How long does it take programmers to fix JavaScript faults?

18

Page 19: An Empirical Study of Client-Side JavaScript Bugs

Finding the Error Location Made use of patches BUT: Patches may be workarounds, not fixes

19

Page 20: An Empirical Study of Client-Side JavaScript Bugs

RQ3 – Error Locations: Results Error Locations

Most errors committed by programmer in JS code itself

20

86%

1% 10%

1% 1% 1%JavaScriptHTMLServer-Side CodeServer Config FileOtherMultiple Error Locations

Page 21: An Empirical Study of Client-Side JavaScript Bugs

Research Questions1. What are the types of faults that exist

among reported bugs, and how prevalent are they?

2. What impact do these JavaScript faults have on the web application?

3. What are the root causes of these JavaScript faults?

4. How long does it take programmers to fix JavaScript faults?

21

Page 22: An Empirical Study of Client-Side JavaScript Bugs

RQ4 – Triage and Fix Times

22

Reported AssignedorCommented

Fixed

TriageTime

FixTime

Page 23: An Empirical Study of Client-Side JavaScript Bugs

RQ4 - Triage and Fix Times: Results

23Triage Time Fix Time

0

10

20

30

40

50

60

70

80

90

100

All FaultsDOM-Related OnlyNon-DOM-Related Only

Aver

age

# o

f D

ays

Page 24: An Empirical Study of Client-Side JavaScript Bugs

Implications Developer tools that reason about DOM

e.g., DOM-aware IDEs Emulate more DOM-related faults in testing Static and dynamic analysis tools

e.g., Vejovis (JS repair suggestion tool)

24

Page 25: An Empirical Study of Client-Side JavaScript Bugs

Threats to Validity Two people classifying bugs possible

consistency issues Non-deterministic and low-visual-impact faults

may go unaccounted for Delays in triage and fix times also

unaccounted for

25

Page 26: An Empirical Study of Client-Side JavaScript Bugs

Conclusion 74% of JS faults Incorrect Method Parameter

faults. 88% of these are DOM-related faults. 80% of high-impact faults are DOM-related Most JS faults are committed by programmers

in the JS code itself DOM-related faults have short triage times but

long fix times compared to non-DOM-related faults

http://ece.ubc.ca/~frolino/projects/js-bugs-study/26