Designing for Extensibility and Planning for Conflict
Total Page:16
File Type:pdf, Size:1020Kb
Designing for Extensibility and Planning for Conflict: Experiments in Web-Browser Design Benjamin S. Lerner A dissertation submitted in partial fulfillment of the requirements for the degree of Doctor of Philosophy University of Washington 2011 Program Authorized to Offer Degree: UW Computer Science & Engineering University of Washington Graduate School This is to certify that I have examined this copy of a doctoral dissertation by Benjamin S. Lerner and have found that it is complete and satisfactory in all respects, and that any and all revisions required by the final examining committee have been made. Chair of the Supervisory Committee: Daniel Grossman Reading Committee: Daniel Grossman Steven Gribble John Zahorjan Date: In presenting this dissertation in partial fulfillment of the requirements for the doctoral degree at the University of Washington, I agree that the Library shall make its copies freely available for inspection. I further agree that extensive copying of this dissertation is allowable only for scholarly purposes, consistent with “fair use” as prescribed in the U.S. Copyright Law. Requests for copying or reproduction of this dissertation may be referred to Proquest Information and Learning, 300 North Zeeb Road, Ann Arbor, MI 48106-1346, 1-800-521-0600, to whom the author has granted “the right to reproduce and sell (a) copies of the manuscript in microform and/or (b) printed copies of the manuscript made from microform.” Signature Date University of Washington Abstract Designing for Extensibility and Planning for Conflict: Experiments in Web-Browser Design Benjamin S. Lerner Chair of the Supervisory Committee: Associate Professor Daniel Grossman UW Computer Science & Engineering The past few years have seen a growing trend in application development toward “web ap- plications”, a fuzzy category of programs that currently (but not necessarily) run within web browsers, that rely heavily on network servers for data storage, and that are developed and de- ployed differently from traditional desktop applications. Where (typical) traditional applications are compiled pieces of code, written in arbitrary languages, that implement both an application’s user interface and its functionality, web apps by contrast are written in three interpreted languages: HTML to define the structure or content of the UI, CSS to define the appearance, and JavaScript (JS) to define the behavior. These three languages feel nothing alike, and are used for different facets of the applications. The last decade has also seen the rise of Mozilla Firefox, a web browser whose UI and func- tionality are themselves written in (dialects of) HTML, CSS, and JS, making Firefox one of the first fully-fledged web apps. Part of Firefox’s appeal is its strong support for extensions, which are downloadable, third-party pieces of code (i.e., not written by Mozilla or with Mozilla’s coopera- tion) that enhance the browser with additional functionality or customizations. Firefox extensions are wildly popular: over six thousand distinct extensions have been downloaded over 2.5 billion times [193], and all major browser vendors have added varying degrees of support for extensions to their own products. Crucially, these extensions are also written in HTML, CSS, and JS: writing an extension feels fundamentally similar to writing a web page or web app. Thanks to the dynamic, interpreted nature of these three languages, it is mostly straightforward to incorporate the contents of an extension into the existing browser. There are, however, some caveats. Not all programs are equally amenable to post-hoc extension, and there are currently no guarantees that multiple extensions do not conflict, destabilizing each other or the base browser. In this dissertation, I aim to provide better support for rich extensibility for web apps. In particular, I claim that Language-specific extension mechanisms are needed for each of HTML, CSS, and JS, and such mechanisms are needed for building useful diagnostic tools to address inter-extension conflicts. To support this thesis, I first present C3, the “Cloud Computing Client”, an implementation of the HTML/CSS/JS platform architected explicitly to support experimentation with extensibility. I then define two such extension mechanisms for HTML and for JS: overlays and aspects, respectively. I develop conflict analyses for HTML overlays, and evaluate them on a sample of Firefox extensions. Conflict analyses for JS are sketched, and extension mechanisms for CSS are left for future work. TABLE OF CONTENTS Page List of Figures . vi Chapter 1: Introduction . 1 1.1 From browsers to platforms . 1 1.2 Positioning extensions . 3 1.2.1 The case for extensions . 6 1.2.2 Designing for power, flexibility and stability . 7 1.3 Contrasting two extension models . 8 1.3.1 Extending the user interface . 8 1.3.2 Extending the functionality . 9 1.4 Proposed support for improving extensions . 11 1.4.1 Necessary platform support . 12 1.4.2 Code extension via aspects . 13 1.4.3 ui extension via semantic overlays . 14 1.4.4 Enforcing security policies . 16 1.5 Summary . 16 Chapter 2: Defining an extension model . 17 2.1 Defining extensibility . 17 2.2 Extensibility in web platforms . 17 2.2.1 The extension development model . 18 2.2.2 The platform level . 19 2.2.3 The webapp level . 20 2.3 Extension mechanisms in existing browsers . 21 2.4 Defining extension models . 25 2.5 Aspect-oriented programming . 26 2.5.1 Language design . 28 2.5.2 Safe aop idioms . 28 2.5.3 Conflict detection among aspects . 30 2.6 Operating systems and other platforms . 31 2.6.1 Static os extensions: Aspects and code management . 32 2.6.2 The Exokernel approach: Composable, pervasive but coarse . 33 2.6.3 The SPIN approach: fine-grained and wide . 34 i 2.6.4 The Singularity approach: Fine-grained, not too wide or narrow . 35 2.6.5 Other platforms . 37 2.7 Feature specification . 39 2.7.1 Logic choice . 40 2.7.2 Termination conditions . 40 2.7.3 Modular checking . 41 2.7.4 Reified features . 42 2.8 Security monitors . 43 2.8.1 Theoretical results . 44 2.8.2 Safety properties and beyond . 45 2.9 Contrasting the web platform with related work . 46 2.10 Summary . 48 Chapter 3: Browser architecture choices for extensibility . 49 3.1 Introduction . 49 3.1.1 Addressing a broader need . 50 3.1.2 Contributions . 51 3.2 C3 architecture and design choices . 51 3.2.1 Pieces of an HTML platform . 52 3.2.2 Modularity . 53 3.2.3 Implementing JS objects . 53 3.2.4 dom implementation . 56 3.2.5 The HTML parser . 60 3.2.6 Computing visual structure . 60 3.2.7 The browser kernel and window proxies . 61 3.2.8 Accommodating privileged ui ........................... 62 3.2.9 Threading architecture . 63 The dom/JS thread(s) . 63 The layout thread(s) . 64 The ui thread . 64 3.3 C3 Extension points . 65 3.3.1 HTML parsing/document construction . 66 3.3.2 JS execution . 70 3.3.3 CSS and layout . 71 3.4 Evaluation . 73 3.4.1 Performance . 73 3.4.2 Expressiveness . 73 XML3D: Extending HTML, CSS and layout . 74 Maverick: Extensions to the global scope . 74 RePriv: Extensions hosting extensions . 75 ii 3.4.3 Other extension models . 75 Shadow doms .................................... 75 Extensions to application ui ............................ 76 Extensions to scripts . 77 3.4.4 Security considerations . 78 3.5 Future work . 78 3.6 Summary . 79 Chapter 4: JS aspects . 81 4.1 Introduction . 81 4.1.1 Aspects for JavaScript . 81 4.1.2 Outline . 82 4.2 Extensible Web-Programming Examples . 83 4.2.1 Reformatting messages in Gmail.