Skip to main content

Combining Form and Function: Static Types for JQuery Programs

  • Conference paper
ECOOP 2013 – Object-Oriented Programming (ECOOP 2013)

Part of the book series: Lecture Notes in Computer Science ((LNPSE,volume 7920))

Included in the following conference series:

Abstract

The jQuery library defines a powerful query language for web applications’ scripts to interact with Web page content. This language is exposed as jQuery’s api, which is implemented to fail silently so that incorrect queries will not cause the program to halt. Since the correctness of a query depends on the structure of a page, discrepancies between the page’s actual structure and what the query expects will also result in failure, but with no error traces to indicate where the mismatch occurred.

This work proposes a novel type system to statically detect jQuery errors. The type system extends Typed JavaScript with local structure about the page and with multiplicities about the structure of containers. Together, these two extensions allow us to track precisely which nodes are active in a jQuery object, with minimal programmer annotation effort. We evaluate this work by applying it to sample real-world jQuery programs.

This work is partially supported by the US National Science Foundation and Google.

This is a preview of subscription content, log in via an institution to check access.

Access this chapter

Chapter
USD 29.95
Price excludes VAT (USA)
  • Available as PDF
  • Read on any device
  • Instant download
  • Own it forever
eBook
USD 39.99
Price excludes VAT (USA)
  • Available as PDF
  • Read on any device
  • Instant download
  • Own it forever
Softcover Book
USD 54.99
Price excludes VAT (USA)
  • Compact, lightweight edition
  • Dispatched in 3 to 5 business days
  • Free shipping worldwide - see info

Tax calculation will be finalised at checkout

Purchases are for personal use only

Institutional subscriptions

Preview

Unable to display preview. Download preview PDF.

Unable to display preview. Download preview PDF.

References

  1. Abel, A.: Polarized subtyping for sized types. Mathematical Structures in Computer Science 18(5), 797–822 (2008)

    Article  MathSciNet  MATH  Google Scholar 

  2. Benzaken, V., Castagna, G., Frisch, A.: CDuce: an XML-centric general-purpose language. In: ACM SIGPLAN International Conference on Functional Programming (ICFP), pp. 51–63. ACM, New York (2003)

    Google Scholar 

  3. Bohannon, A., Pierce, B.C.: Featherweight Firefox: formalizing the core of a web browser. In: USENIX Conference on Web Application Development (WebApps), pp. 123–134. USENIX Association, Berkeley (2010)

    Google Scholar 

  4. BuiltWith. JQuery usage statistics, http://trends.builtwith.com/javascript/JQuery (retrieved November 2012)

  5. Castagna, G., Colazzo, D., Frisch, A.: Error mining for regular expression patterns. In: Coppo, M., Lodi, E., Pinna, G.M. (eds.) ICTCS 2005. LNCS, vol. 3701, pp. 160–172. Springer, Heidelberg (2005)

    Chapter  Google Scholar 

  6. Chaffer, J., Swedberg, K.: Learning JQuery, 3rd edn. Packt Publishing Ltd., Birmingham (2011)

    Google Scholar 

  7. Gardner, P., Wheelhouse, M.: Small specifications for tree update. In: Laneve, C., Su, J. (eds.) WS-FM 2009. LNCS, vol. 6194, pp. 178–195. Springer, Heidelberg (2010)

    Chapter  Google Scholar 

  8. Gardner, P.A., Smith, G.D., Wheelhouse, M.J., Zarfaty, U.D.: Local Hoare reasoning about DOM. In: ACM SIGMOD Symposium on Principles of Database Systems (PODS), pp. 261–270. ACM Press, New York (2008)

    Google Scholar 

  9. Guha, A., Saftoiu, C., Krishnamurthi, S.: The essence of JavaScript. In: D’Hondt, T. (ed.) ECOOP 2010. LNCS, vol. 6183, pp. 126–150. Springer, Heidelberg (2010)

    Chapter  Google Scholar 

  10. Guha, A., Saftoiu, C., Krishnamurthi, S.: Typing local control and state using flow analysis. In: Barthe, G. (ed.) ESOP 2011. LNCS, vol. 6602, pp. 256–275. Springer, Heidelberg (2011)

    Chapter  Google Scholar 

  11. Hosoya, H., Pierce, B.C.: XDuce: A statically typed XML processing language. ACM Transactions on Internet Technology (TOIT) 3(2), 117–148 (2003)

    Article  Google Scholar 

  12. Lerner, B.S.: Designing for Extensibility and Planning for Conflict: Experiments in Web-Browser Design. Ph.D. thesis, University of Washington Computer Science & Engineering (August 2011)

    Google Scholar 

  13. Lerner, B.S., Carroll, M.J., Kimmel, D.P., de la Vallee, H.Q., Krishnamurthi, S.: Modeling and reasoning about DOM events. In: USENIX Conference on Web Application Development (WebApps). USENIX Association, Berkeley (2012)

    Google Scholar 

  14. Maffeis, S., Mitchell, J.C., Taly, A.: An operational semantics for JavaScript. In: Ramalingam, G. (ed.) APLAS 2008. LNCS, vol. 5356, pp. 307–325. Springer, Heidelberg (2008)

    Chapter  Google Scholar 

  15. Politz, J.G., Carroll, M., Lerner, B.S., Pombrio, J., Krishnamurthi, S.: A tested semantics for getters, setters, and eval in JavaScript. In: Dynamic Languages Symposium (DLS) (2012)

    Google Scholar 

  16. Politz, J.G., Eliopoulos, S.A., Guha, A., Krishnamurthi, S.: ADsafety: type-based verification of JavaScript sandboxing. In: USENIX Security Symposium, p. 12. USENIX Association, Berkeley (2011)

    Google Scholar 

  17. Politz, J.G., Guha, A., Krishnamurthi, S.: Semantics and types for objects with first-class member names. In: Workshop on Foundations of Object-Oriented Languages (FOOL) (2012)

    Google Scholar 

  18. St-Amour, V., Tobin-Hochstadt, S., Flatt, M., Felleisen, M.: Typing the numeric tower. In: Russo, C., Zhou, N.-F. (eds.) PADL 2012. LNCS, vol. 7149, pp. 289–303. Springer, Heidelberg (2012)

    Chapter  Google Scholar 

  19. Sulzmann, M., Lu, K.Z.M.: A type-safe embedding of XDuce into ML. In: Workshop on ML, pp. 229–253. ACM Press, New York (2005)

    Google Scholar 

  20. Swedberg, K.: How to get anything you want - part 1, http://www.learningjquery.com/2006/11/how-to-get-anything-you-want-part-1 (written November 2006)

  21. Swedberg, K.: How to get anything you want - part 2, http://www.learningjquery.com/2006/12/how-to-get-anything-you-want-part-2 (written December 2006)

  22. Tobin-Hochstadt, S., Felleisen, M.: The design and implementation of Typed Scheme. In: ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages (POPL), pp. 395–406. ACM Press, New York (2008)

    Google Scholar 

  23. W3C. XML path language (XPath) 2.0, http://www.w3.org/TR/xpath20/ (written December 2010)

  24. W3C. XQuery 1.0: An XML query language, http://www.w3.org/TR/xquery/ (written December 2010)

  25. W3C. Selectors level 3, http://www.w3.org/TR/selectors/ (written Septmber 2010)

  26. Zenger, C.: Indexed types. Theoretical Computer Science 187(1-2), 147–165 (1997)

    Article  MathSciNet  MATH  Google Scholar 

Download references

Author information

Authors and Affiliations

Authors

Editor information

Editors and Affiliations

Rights and permissions

Reprints and permissions

Copyright information

© 2013 Springer-Verlag Berlin Heidelberg

About this paper

Cite this paper

Lerner, B.S., Elberty, L., Li, J., Krishnamurthi, S. (2013). Combining Form and Function: Static Types for JQuery Programs. In: Castagna, G. (eds) ECOOP 2013 – Object-Oriented Programming. ECOOP 2013. Lecture Notes in Computer Science, vol 7920. Springer, Berlin, Heidelberg. https://doi.org/10.1007/978-3-642-39038-8_4

Download citation

  • DOI: https://doi.org/10.1007/978-3-642-39038-8_4

  • Publisher Name: Springer, Berlin, Heidelberg

  • Print ISBN: 978-3-642-39037-1

  • Online ISBN: 978-3-642-39038-8

  • eBook Packages: Computer ScienceComputer Science (R0)

Publish with us

Policies and ethics