Skip to content

Private browsing student project

Josh Matthews edited this page Feb 9, 2016 · 3 revisions

Implement private browsing

Background information: All major web browsers support a mode where persistent data such as cookies, logins, history, and downloads are forgotten after the session ends. Additionally, this mode is allowed to run concurrently with the regular, persistent session, without the data from either one interfering with the other. Servo is currently designed around global, shared storage for these sorts of features and therefore lacks this mode. The goal of this project is to implement support for this session partitioning feature.

Initial steps:

  • compile Servo and ensure that it runs on tests/html/about-mozilla.html
  • email the mozilla.dev.servo mailing list introducing your group and your progress
  • add a member to the IFrameLoadInfo struct that indicates if the iframe is private or not. Set this member based on the presence of the mozprivatebrowsing attribute on the iframe element, but only if it's a mozbrowser iframe too.
  • add a field to the Pipeline struct that indicates if the pipeline is private or not. Set this member as part of calling new_pipeline from handle_script_loaded_url_in_iframe_msg.
  • define a ConstellationMsg enum in components/net_traits/lib.rs which has a IsPrivate message that contains a PipelineId as well as a Sender<bool> value for returning an answer. Add a method to Constellation that can process the "is this pipeline private" request and send an appropriate reply. This must check the provided pipeline for privacy, as well as any ancestors.

Subsequent steps:

  • create an automated test for the desired functionality - an iframe that performs an XHR that sends a cookie and checks localstorage, and the same iframe but private that shows independent results. This will need to live in tests/wpt/mozilla/tests/mozilla/mozbrowser/ (see other tests there for inspiration).
  • add a "New private tab" button to servo-shell to allow using the new feature. It should set the mozprivatebrowsing attribute on the new tab that is created.
  • add a Receiver member to Constellation that can receive the new ConstellationMsg enum defined previously. Create a channel in Constellation::start, send the Sender value to the ResourceThread, and use the receiver in Constellation::handle_request to receive messages and call the new method previously defined.
  • define a new struct in resource_thread.rs which encapsulates the cookie_storage, hsts_list, and connector values. Replace these members with two instances of the new type. Create a method that accepts an optional PipelineId value and returns a reference to the new type, returning an appropriate instance based on whether the pipeline should be treated as private or not.
  • repeat the two previous steps for StorageThread in storage_thread.rs, in order to handle localStorage and sessionStorage in the same manner.
Clone this wiki locally