AutoFLox: An Automatic Fault Localizer for Client-Side JavaScript Frolin S. Ocariza, Jr. Karthik Pattabiraman Ali Mesbah University of British Columbia.

Slides:



Advertisements
Similar presentations
TWO STEP EQUATIONS 1. SOLVE FOR X 2. DO THE ADDITION STEP FIRST
Advertisements

Copyright © 2008 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 2 Introduction to XHTML Programming the World Wide Web Fourth edition.
Advanced Piloting Cruise Plot.
Copyright © 2003 Pearson Education, Inc. Slide 3-1 Created by Cheryl M. Hughes The Web Wizards Guide to XML by Cheryl M. Hughes.
© 2008 Pearson Addison Wesley. All rights reserved Chapter Seven Costs.
Copyright © 2003 Pearson Education, Inc. Slide 1 Computer Systems Organization & Architecture Chapters 8-12 John D. Carpinelli.
Chapter 1 The Study of Body Function Image PowerPoint
© 2010 Pearson Addison-Wesley. All rights reserved. Addison Wesley is an imprint of Chapter 11: Structure and Union Types Problem Solving & Program Design.
6 Copyright © 2005, Oracle. All rights reserved. Building Applications with Oracle JDeveloper 10g.
Jeopardy Q 1 Q 6 Q 11 Q 16 Q 21 Q 2 Q 7 Q 12 Q 17 Q 22 Q 3 Q 8 Q 13
Jeopardy Q 1 Q 6 Q 11 Q 16 Q 21 Q 2 Q 7 Q 12 Q 17 Q 22 Q 3 Q 8 Q 13
Title Subtitle.
Multiplying binomials You will have 20 seconds to answer each of the following multiplication problems. If you get hung up, go to the next problem when.
DIVIDING INTEGERS 1. IF THE SIGNS ARE THE SAME THE ANSWER IS POSITIVE 2. IF THE SIGNS ARE DIFFERENT THE ANSWER IS NEGATIVE.
MULTIPLICATION EQUATIONS 1. SOLVE FOR X 3. WHAT EVER YOU DO TO ONE SIDE YOU HAVE TO DO TO THE OTHER 2. DIVIDE BY THE NUMBER IN FRONT OF THE VARIABLE.
FACTORING ax2 + bx + c Think “unfoil” Work down, Show all steps.
Addition Facts
Year 6 mental test 5 second questions
Making the System Operational
1 A Tool-box for Web-site Maintenance Manjula Patel UKOLN University of Bath Bath, BA2 7AY UKOLN is funded by the Library and Information Commission, the.
View-Based Application Development Lecture 1 1. Flows of Lecture 1 Before Lab Introduction to the Game to be developed in this workshop Comparison between.
Excel Functions. Part 1. Introduction 2 An Excel function is a formula or a procedure that is performed in the Visual Basic environment, outside the.
Proud Members of the Consulting Group, LLC
Solve Multi-step Equations
REVIEW: Arthropod ID. 1. Name the subphylum. 2. Name the subphylum. 3. Name the order.
Report Card P Only 4 files are exported in SAMS, but there are at least 7 tables could be exported in WebSAMS. Report Card P contains 4 functions: Extract,
Intel VTune Yukai Hong Department of Mathematics National Taiwan University July 24, 2008.
Configuration management
Software testing.
Data Structures Using C++
Campaign Overview Mailers Mailing Lists
ABC Technology Project
Chapter 9 -- Simplification of Sequential Circuits.
1 Undirected Breadth First Search F A BCG DE H 2 F A BCG DE H Queue: A get Undiscovered Fringe Finished Active 0 distance from A visit(A)
© Copyright by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. 1 Tutorial 12 – Security Panel Application Introducing.
1 What is JavaScript? JavaScript was designed to add interactivity to HTML pages JavaScript is a scripting language A scripting language is a lightweight.
VOORBLAD.
Benchmark Series Microsoft Excel 2013 Level 2
BIOLOGY AUGUST 2013 OPENING ASSIGNMENTS. AUGUST 7, 2013  Question goes here!
Factor P 16 8(8-5ab) 4(d² + 4) 3rs(2r – s) 15cd(1 + 2cd) 8(4a² + 3b²)
Squares and Square Root WALK. Solve each problem REVIEW:
Basel-ICU-Journal Challenge18/20/ Basel-ICU-Journal Challenge8/20/2014.
1..
© 2012 National Heart Foundation of Australia. Slide 2.
Lets play bingo!!. Calculate: MEAN Calculate: MEDIAN
Chapter 10 Software Testing
LO: Count up to 100 objects by grouping them and counting in 5s 10s and 2s. Mrs Criddle: Westfield Middle School.
Understanding Generalist Practice, 5e, Kirst-Ashman/Hull
Chapter 5 Test Review Sections 5-1 through 5-4.
Macromedia Dreamweaver MX 2004 – Design Professional Dreamweaver GETTING STARTED WITH.
Addition 1’s to 20.
25 seconds left…...
Januar MDMDFSSMDMDFSSS
Week 1.
Types of selection structures
We will resume in: 25 Minutes.
©Brooks/Cole, 2001 Chapter 12 Derived Types-- Enumerated, Structure and Union.
Intracellular Compartments and Transport
PSSA Preparation.
Experimental Design and Analysis of Variance
Chapter 11 Creating Framed Layouts Principles of Web Design, 4 th Edition.
Essential Cell Biology
Chapter 13 Web Page Design Studio
CpSc 3220 Designing a Database
1 Programming Languages (CS 550) Mini Language Interpreter Jeremy R. Johnson.
An Empirical Study of Client-Side JavaScript Bugs Frolin S. Ocariza, Jr. Kartik Bajaj, Karthik Pattabiraman, Ali Mesbah University of British Columbia.
Presentation transcript:

AutoFLox: An Automatic Fault Localizer for Client-Side JavaScript Frolin S. Ocariza, Jr. Karthik Pattabiraman Ali Mesbah University of British Columbia

Web 2.0 Applications: JavaScript  JavaScript: Implementation of ECMAScript standard  Client-Side JavaScript: used to develop web apps  Executes at client’s browser  Web application’s functionality  Dependability problem: Average of 4 errors per web app in the wild [ISSRE11] 2

JavaScript Dependability: Document Object Model (DOM) 3 html bodyhead scriptdivp Text: “Hello world” table trp Element added by JavaScript Element removed by JavaScript

JavaScript Dependability: Document Object Model (DOM) 4 div id: elem JavaScript code: DOM: var x = document.getElementById(“elem”);var x = document.getElementById(“elme”); Inexistent ID Will return null DOM-related JavaScript error

Fault Localization  Web application testing  What to do after we find errors? Need to fix them…  Fault localization: Find the root cause of the error 5

Contributions/Outline 1. Discussion of JavaScript fault localization challenges 2. Automated technique to localize DOM-related JavaScript faults 3. Empirical studies  Highlight prevalence of DOM-related JavaScript errors  Evaluate accuracy and performance of technique 6

1 function changeBanner(bannerID) { 2 clearTimeout(changeTimer); 3 changeTimer = setTimeout(changeBanner, 5000); 4 5 prefix = “banner_”; 6 currBannerElem = document.getElementById(prefix+currentBannerID); 7 bannerToChange = document.getElementById(prefix + bannerID); 8 currBannerElem.removeClassName(“active”); 9 bannerToChange.addClassName(“active”); 10 currentBannerID = bannerID; 11 } 12 currentBannerID = 1; 13 changeTimer = setTimeout(changeBanner, 5000); Running Example 7 1 function changeBanner(bannerID) { 2 clearTimeout(changeTimer); 3 changeTimer = setTimeout(changeBanner, 5000); 4 5 prefix = “banner_”; 6 currBannerElem = document.getElementById(prefix+currentBannerID); 7 bannerToChange = document.getElementById(prefix + bannerID); 8 currBannerElem.removeClassName(“active”); 9 bannerToChange.addClassName(“active”); 10 currentBannerID = bannerID; 11 } 12 currentBannerID = 1; 13 changeTimer = setTimeout(changeBanner, 5000);  Goal: Show a fading banner that cycles through four images every 5 seconds Passed with no argument (even though changeBanner needs one argument) bannerID will be set randomly Would return null if bannerID out of range NULL EXCEPTION! setTimeout call

1 function changeBanner(bannerID) { 2 clearTimeout(changeTimer); 3 changeTimer = setTimeout(changeBanner, 5000); 4 5 prefix = “banner_”; 6 currBannerElem = document.getElementById(prefix+currentBannerID); 7 bannerToChange = document.getElementById(prefix + bannerID); 8 currBannerElem.removeClassName(“active”); 9 bannerToChange.addClassName(“active”); 10 currentBannerID = bannerID; 11 } 12 currentBannerID = 1; 13 changeTimer = setTimeout(changeBanner, 5000); JavaScript Fault Localization: Challenges  Multiple JS execution sequences executing asynchronously 8 1 function changeBanner(bannerID) { 2 clearTimeout(changeTimer); 3 changeTimer = setTimeout(changeBanner, 5000); 4 5 prefix = “banner_”; 6 currBannerElem = document.getElementById(prefix+currentBannerID); 7 bannerToChange = document.getElementById(prefix + bannerID); 8 currBannerElem.removeClassName(“active”); 9 bannerToChange.addClassName(“active”); 10 currentBannerID = bannerID; 11 } 12 currentBannerID = 1; 13 changeTimer = setTimeout(changeBanner, 5000); 1 function changeBanner(bannerID) { 2 clearTimeout(changeTimer); 3 changeTimer = setTimeout(changeBanner, 5000); 4 5 prefix = “banner_”; 6 currBannerElem = document.getElementById(prefix+currentBannerID); 7 bannerToChange = document.getElementById(prefix + bannerID); 8 currBannerElem.removeClassName(“active”); 9 bannerToChange.addClassName(“active”); 10 currentBannerID = bannerID; 11 } 12 currentBannerID = 1; 13 changeTimer = setTimeout(changeBanner, 5000); Sequence 1 Sequence 2

1 function changeBanner(bannerID) { 2 clearTimeout(changeTimer); 3 changeTimer = setTimeout(changeBanner, 5000); 4 5 prefix = “banner_”; 6 currBannerElem = document.getElementById(prefix+currentBannerID); 7 bannerToChange = document.getElementById(prefix + bannerID); 8 currBannerElem.removeClassName(“active”); 9 bannerToChange.addClassName(“active”); 10 currentBannerID = bannerID; 11 } 12 currentBannerID = 1; 13 changeTimer = setTimeout(changeBanner, 5000); 1 function changeBanner(bannerID) { 2 clearTimeout(changeTimer); 3 changeTimer = setTimeout(changeBanner, 5000); 4 5 prefix = “banner_”; 6 currBannerElem = document.getElementById(prefix+currentBannerID); 7 bannerToChange = document.getElementById(prefix + bannerID); 8 currBannerElem.removeClassName(“active”); 9 bannerToChange.addClassName(“active”); 10 currentBannerID = bannerID; 11 } 12 currentBannerID = 1; 13 changeTimer = setTimeout(changeBanner, 5000); JavaScript Fault Localization: Challenges (2)  DOM-related JS Errors – fault can be in JS code or DOM – find direct DOM access 9 direct DOM access

element = $(“elem”); b = element.getAttribute(“badAttr”) element.innerHTML = “text”; b.value = “newValue”; Scope of Technique  Types of DOM-related JS errors 10 Code-terminating DOM-related JS errors exception Output DOM-related JS errors function changeToBlue(elem) { elem.style.color = “red”; } Wrong colour change

Block Diagram 11 Instrument JS Code Run Web Application Generate Traces Analyze backward slice Extract Relevant Sequence Partition into Sequences Trace file Web Application direct DOM access Trace Collection Phase Trace Analysis Phase

Trace Collection 1. Intercept JS code in web app and instrument each line 2. Run web app – instrumentation will execute for each line that executes 3. Generate a dynamic trace of all executed lines 12 - Trace contains line number, function name, and values of in-scope variables - Error marker also in trace Instrument JS Code Run Web Application Generate Traces Trace file Web Application 1 function changeBanner(bannerID) { 2 clearTimeout(changeTimer); 3 changeTimer = setTimeout(changeBanner, 5000); 4 5 prefix = “banner_”; 6 currBannerElem = document.getElementById(prefix+currentBannerID); 7 bannerToChange = document.getElementById(prefix + bannerID); 8 currBannerElem.removeClassName(“active”); 9 bannerToChange.addClassName(“active”); 10 currentBannerID = bannerID; 11 } 12 currentBannerID = 1; 13 changeTimer = setTimeout(changeBanner, 5000); 1 function changeBanner(bannerID) { 2 clearTimeout(changeTimer); trace(); 3 changeTimer = setTimeout(changeBanner, 5000); trace(); 4 5 prefix = “banner_”; trace(); 6 currBannerElem = document.getElementById(prefix+currentBannerID);trace(); 7 bannerToChange = document.getElementById(prefix + bannerID); trace(); 8 currBannerElem.removeClassName(“active”); trace(); 9 bannerToChange.addClassName(“active”); trace(); 10 currentBannerID = bannerID; trace(); 11 } 12 currentBannerID = 1; trace(); 13 changeTimer = setTimeout(changeBanner, 5000); trace(); 1 function changeBanner(bannerID) { 2 clearTimeout(changeTimer); trace(); 3 changeTimer = setTimeout(changeBanner, 5000); trace(); 4 5 prefix = “banner_”; trace(); 6 currBannerElem = document.getElementById(prefix+currentBannerID);trace(); 7 bannerToChange = document.getElementById(prefix + bannerID); trace(); 8 currBannerElem.removeClassName(“active”); trace(); 9 bannerToChange.addClassName(“active”); trace(); 10 currentBannerID = bannerID; trace(); 11 } 12 currentBannerID = 1; trace(); 13 changeTimer = setTimeout(changeBanner, 5000); trace(); Trace Record Prefix: changeBanner:::4 Variables: currentBannerID (global): 1 changeTimer (global): 2 bannerID (local): -11 prefix (local): none currBannerElem (local): none bannerToChange (local): none

Trace Analysis 1. Trace is divided into sequences 2. Relevant sequence – execution sequence that contains error marker 3. Analyze backward slice of last variable that held null to see where null value originated. The line where null value originated is the direct DOM access. 13 Instrument JS Code Run Web Application Generate Traces Analyze backward slice Extract Relevant Sequence Partition into Sequences Trace file direct DOM access Web Application

1 function changeBanner(bannerID) { 2 clearTimeout(changeTimer); 3 changeTimer = setTimeout(changeBanner, 5000); 4 5 prefix = “banner_”; 6 currBannerElem = document.getElementById(prefix+currentBannerID); 7 bannerToChange = document.getElementById(prefix + bannerID); 8 currBannerElem.removeClassName(“active”); 9 bannerToChange.addClassName(“active”); 10 currentBannerID = bannerID; 11 } 12 currentBannerID = 1; 13 changeTimer = setTimeout(changeBanner, 5000); Sequences.: (1) line2 -> line3 -> line5 -> line6 -> line7 -> line8 -> line9 (2) line12 -> line13 Trace Analysis: Example 1 function changeBanner(bannerID) { 2 clearTimeout(changeTimer); 3 changeTimer = setTimeout(changeBanner, 5000); 4 5 prefix = “banner_”; 6 currBannerElem = document.getElementById(prefix+currentBannerID); 7 bannerToChange = document.getElementById(prefix + bannerID); 8 currBannerElem.removeClassName(“active”); 9 bannerToChange.addClassName(“active”); 10 currentBannerID = bannerID; 11 } 12 currentBannerID = 1; 13 changeTimer = setTimeout(changeBanner, 5000); 14 Relevant Seq.: line12 -> line13 -> line2 -> line3 -> line5 -> line6 -> line7 -> line8 -> line9 1 function changeBanner(bannerID) { 2 clearTimeout(changeTimer); 3 changeTimer = setTimeout(changeBanner, 5000); 4 5 prefix = “banner_”; 6 currBannerElem = document.getElementById(prefix+currentBannerID); 7 bannerToChange = document.getElementById(prefix + bannerID); 8 currBannerElem.removeClassName(“active”); 9 bannerToChange.addClassName(“active”); 10 currentBannerID = bannerID; 11 } 12 currentBannerID = 1; 13 changeTimer = setTimeout(changeBanner, 5000); 1 function changeBanner(bannerID) { 2 clearTimeout(changeTimer); 3 changeTimer = setTimeout(changeBanner, 5000); 4 5 prefix = “banner_”; 6 currBannerElem = document.getElementById(prefix+currentBannerID); 7 bannerToChange = document.getElementById(prefix + bannerID); 8 currBannerElem.removeClassName(“active”); 9 bannerToChange.addClassName(“active”); 10 currentBannerID = bannerID; 11 } 12 currentBannerID = 1; 13 changeTimer = setTimeout(changeBanner, 5000); bannerToChange being assigned return value of DOM access function Error Marker Technique outputs this line as direct DOM access Last variable to take on null value

Implementation of AutoFLox  Trace Collection: Modified versions of existing tools (InvarScope [Groeneveld et al.] and Crawljax [Mesbah et al.])  Trace Analysis: Written from scratch 15

Evaluation: Research Questions  RQ1: How prominent are DOM-related JavaScript errors in web applications?  RQ2: What is the fault localization accuracy of AutoFLox?  RQ3: What is the performance overhead of AutoFLox? 16

Prominence of DOM-related JS Errors  RQ1 Approach: Study bug reports of four web apps (TUDU, TaskFreak, WordPress, and Google)  Only JS-related bugs marked valid or fixed are studied 17

Research Questions  RQ1: How prominent are DOM-related JavaScript errors in web applications?  RQ2: What is the fault localization accuracy of AutoFLox?  RQ3: What is the performance overhead of AutoFLox? 18

Accuracy of AutoFLox  RQ2 Approach: Fault injection experiment on TUDU, TaskFreak, and WordPress  Faults injected: Null exceptions  Mutate the parameters of getElementById and getAttribute methods 19

Accuracy of AutoFLox: Results  WordPress: anonymous functions not supported by AutoFLox at the moment  Direct DOM access in Tumblr also found 20 Web AppTotal Number of Mutations Number of direct DOM accesses identified Percentage identified TaskFreak29 100% TUDU24 100% WordPress % Overall %

Research Questions  How prominent are DOM-related JavaScript errors in web applications?  What is the fault localization accuracy of AutoFLox?  What is the performance overhead of AutoFLox? 21

Performance  RQ3 Approach: Measure trace collection overhead in Tumblr; measure time it takes for trace analysis to complete  Tumblr used because production code more complex than development code  Results  Trace collection incurred 35% overhead  Trace analysis took seconds to complete 22

Conclusion  DOM-related JS errors are prevalent  Created fault localization tool for JS called AutoFLox   Evaluated accuracy and performance of AutoFLox  Future work  Relax simplifying assumptions  Target Output DOM-related JS errors  Automatically fixing DOM-related JS errors 23

Backup Slides

25 Web 2.0 Applications: Document Object Model - Defines elements contained in webpage

Dependability Problems in JavaScript  Big contributing factor: JS interaction with Document Object Model (DOM) 26 DIV id: elem DOMJavaScript Code var x = document.getElementById(“elem”); var x = document.getElementById(“elme”); Will return nullInexistent ID DOM-related JavaScript error

Fault Localization  Web application testing  What to do after we find errors? Need to fix them…  Fault localization: Find the root cause of the error 27 x = document.getElementById(“elme”); changeText(x); ….. function changeText(domElement) { y = domElement; y.innerHTML = ‘New Text’; } exception root cause

Running Example 28 1 function changeBanner(bannerID) { 2 clearTimeout(changeTimer); 3 changeTimer = setTimeout(changeBanner, 5000); 4 5 prefix = “banner_”; 6 currBannerElem = document.getElementById(prefix+currentBannerID); 7 bannerToChange = document.getElementById(prefix + bannerID); 8 currBannerElem.removeClassName(“active”); 9 bannerToChange.addClassName(“active”); 10 currentBannerID = bannerID; 11 } 12 currentBannerID = 1; 13 changeTimer = setTimeout(changeBanner, 5000); Passed with no argument (even though changeBanner needs one argument) bannerID will be set randomly Would return null if bannerID out of range NULL EXCEPTION!

AutoFLox: Scope  Types of DOM-related JS errors  Code-terminating DOM-related JavaScript Errors: Errors that occur when DOM access function returns null, undefined, or incorrect value  Output DOM-related JavaScript Errors: Errors that occur when DOM update function sets DOM element’s property to wrong value 29 AutoFLox is concerned with code-terminating DOM-related JavaScript errors

Limitations  User has to know how to replicate error  User required to specify elements to click during crawling  Multiple JS errors currently not supported 30