addon-sdk/source/test/traits/utils.js

Thu, 15 Jan 2015 15:59:08 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 15 Jan 2015 15:59:08 +0100
branch
TOR_BUG_9701
changeset 10
ac0c01689b40
permissions
-rw-r--r--

Implement a real Private Browsing Mode condition by changing the API/ABI;
This solves Tor bug #9701, complying with disk avoidance documented in
https://www.torproject.org/projects/torbrowser/design/#disk-avoidance.

     1 /* This Source Code Form is subject to the terms of the Mozilla Public
     2  * License, v. 2.0. If a copy of the MPL was not distributed with this
     3  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
     5 "use strict";
     7 var ERR_CONFLICT = "Remaining conflicting property: ";
     8 var ERR_REQUIRED = "Missing required property: ";
    10 exports.Data = function Data(value, enumerable, configurable, writable) {
    11   return ({
    12     value: value,
    13     enumerable: enumerable !== false,
    14     configurable: configurable !== false,
    15     writable: writable !== false
    16   });
    17 };
    19 exports.Method = function Method(method, enumerable, configurable, writable) {
    20   return ({
    21     value: method,
    22     enumerable: enumerable !== false,
    23     configurable: configurable !== false,
    24     writable: writable !== false
    25   });
    26 };
    28 exports.Accessor = function Accessor(get, set, enumerable, configurable) {
    29   return ({
    30     get: get,
    31     set: set,
    32     enumerable: enumerable !== false,
    33     configurable: configurable !== false
    34   });
    35 };
    37 exports.Required = function Required(name) {
    38   function required() { throw new Error(ERR_REQUIRED + name) }
    40   return ({
    41     get: required,
    42     set: required,
    43     required: true
    44   });
    45 };
    47 exports.Conflict = function Conflict(name) {
    48   function conflict() { throw new Error(ERR_CONFLICT + name) }
    50   return ({
    51     get: conflict,
    52     set: conflict,
    53     conflict: true
    54   });
    55 };

mercurial