Download presentation
Presentation is loading. Please wait.
Published byAxel Toney Modified over 9 years ago
1
Language Support for Extensible Web Browsers Benjamin Lerner and Dan Grossman
2
Position Browser extensions are a good thing What are extensions? What are extensions? Why use them? Why use them? Current approaches have important flaws False design tradeoffs False design tradeoffs Languages used are poor Languages used are poor PL techniques can help UI: declarative compositional overlays UI: declarative compositional overlays Behavior: aspects Behavior: aspects 2
3
What are web-browser extensions? Downloadable code to customize the browser Different from plugins 3
4
Why extensions? Extensions avoid bloat Pick and choose the features you want Pick and choose the features you want Extensions can experiment Provide new features after products ship Provide new features after products ship Wildly popular: 6,000+ extensions 6,000+ extensions 1.5 Billion downloads 1.5 Billion downloads 4
5
What’s wrong with extensions today? Two browser designs: Firefox and Chrome The designs force a trade-off: Huge flexibility, or Huge flexibility, or Robustness Robustness For both, the programming model is very poor Why can’t we do better? 5
6
Programming example: Mouse Gestures “Right-click-and-drag” gestures Shape of gesture browser command Work-alike versions for Chrome and Firefox 6
7
Firefox: flexible but brittle Firebug + YSlow, Firefinder, FireCookie… Deliberately extend another extension Deliberately extend another extension http://sixrevisions.com/web-development/10-useful-firefox-extensions-to- supercharge-firebug/http://sixrevisions.com/web-development/10-useful-firefox-extensions-to- supercharge-firebug/http://sixrevisions.com/web-development/10-useful-firefox-extensions-to- supercharge-firebug/http://sixrevisions.com/web-development/10-useful-firefox-extensions-to- supercharge-firebug/ AdBlock Plus + NoScript Deliberately break another extension Deliberately break another extension http://hackademix.net/2009/05/04/dear-adblock-plus-and-noscript-users-dear- mozilla-community/http://hackademix.net/2009/05/04/dear-adblock-plus-and-noscript-users-dear- mozilla-community/http://hackademix.net/2009/05/04/dear-adblock-plus-and-noscript-users-dear- mozilla-community/http://hackademix.net/2009/05/04/dear-adblock-plus-and-noscript-users-dear- mozilla-community/ Currently no way to distinguish these cases 7
8
Firefox: free-form code injection aioContent = document.getElementById("content"); aioContent.aioNativeRemoveTab = aioContent.removeTab; eval("aioContent.aioNativeRemoveTab = " + aioContent.aioNativeRemoveTab.toString().replace( 'this.selectedTab', 'this.selectedTab', '…various replacement code…')); '…various replacement code…')); aioContent.removeTab = function(aTab) { …various preprocessing… …various preprocessing… aioContent.aioNativeRemoveTab(aTab); aioContent.aioNativeRemoveTab(aTab);} Get a reference to the main window Alias the removeTab function Modify the function at that alias Replace the original with a call to the modified version 8
9
Chrome: robust but limited StumbleUpon Provides a “toolbar” in the page, Provides a “toolbar” in the page, …but it’s not a true chrome toolbar …but it’s not a true chrome toolbar http://www.stumbleupon.com/sublog/su_chrome_extension/http://www.stumbleupon.com/sublog/su_chrome_extension/http://www.stumbleupon.com/sublog/su_chrome_extension/ Currently no fix without new APIs 9
10
Chrome: tightly-constrained In the background page: close_tab:function(tab){ chrome.tabs.remove(tab.id); chrome.tabs.remove(tab.id);}, Injected into the main page: var ACTION = { … "close this tab" : function(){ "close this tab" : function(){ connection.postMessage('close_tab'); connection.postMessage('close_tab'); }, }, …} Predefined object to manipulate tabs Page communicates to background via postMessage API 10
11
Towards a middle ground Goal: flexibility and robustness Free-form UI extension Free-form UI extension Benign extensions can extend each other Benign extensions can extend each other Malicious extensions can’t hurt each other Malicious extensions can’t hurt each other Separate techniques for UI and code: UI: Declarative, compositional overlays UI: Declarative, compositional overlays Code: aspects Code: aspects 11
12
Overlays Intuition: “Tree-structured patch” When are overlays successfully applied? When are overlays in conflict? When should overlays be prohibited? Hello World Hello World 12
13
Compositional overlays The tree-patching part is fine, but need to: Declare expectations of the base document Declare invariants asserted by the overlay Can now detect conflicting assertions 13 Require “greeting” Last “greeting” (“greeting”, World ) Require “greeting” Last “greeting” (“greeting”, World ) Require “greeting” Last “greeting” (“greeting”, Toronto ) Require “greeting” Last “greeting” (“greeting”, Toronto ) Last “greeting”
14
Programming redux: using aspects aioContent = document.getElementById("content"); aioContent.aioNativeRemoveTab = aioContent.removeTab; eval("aioContent.aioNativeRemoveTab = " + aioContent.aioNativeRemoveTab.toString().replace( 'this.selectedTab', 'this.selectedTab', '…various replacement code…')); '…various replacement code…')); aioContent.removeTab = function(aTab) { …various preprocessing… …various preprocessing… aioContent.aioNativeRemoveTab(aTab); aioContent.aioNativeRemoveTab(aTab);} Get a reference to the main window Alias the removeTab function Advise field accesses explicitly Add before advice to the function aioContent = document.getElementById("content"); aioContent.aioNativeRemoveTab = aioContent.removeTab; at pointcut(field(this.selectedTab) && within(aioContent.removeTab)) around { get { …various replacement code… } }; at pointcut(callee(aioContent.removeTab)) before (aTab) { before (aTab) { …various preprocessing… …various preprocessing…} Come to OOPSLA for more details When are aspects successfully woven? When should aspects be prohibited? 14
15
Conclusion Browser extensions are here to stay Programming them needs our help Two potential techniques: UI: compositional overlays UI: compositional overlays Code: aspects Code: aspects 15
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.