Thu, 15 Jan 2015 15:59:08 +0100
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.
michael@0 | 1 | /* This Source Code Form is subject to the terms of the Mozilla Public |
michael@0 | 2 | * License, v. 2.0. If a copy of the MPL was not distributed with this |
michael@0 | 3 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
michael@0 | 4 | 'use strict' |
michael@0 | 5 | |
michael@0 | 6 | const { Cu, Cc, Ci } = require('chrome'); |
michael@0 | 7 | const Request = require('sdk/request').Request; |
michael@0 | 8 | const { WindowTracker } = require('sdk/deprecated/window-utils'); |
michael@0 | 9 | const { close, open } = require('sdk/window/helpers'); |
michael@0 | 10 | |
michael@0 | 11 | const XUL_URL = 'chrome://test/content/new-window.xul' |
michael@0 | 12 | |
michael@0 | 13 | const { Services } = Cu.import('resource://gre/modules/Services.jsm', {}); |
michael@0 | 14 | const { NetUtil } = Cu.import('resource://gre/modules/NetUtil.jsm', {}); |
michael@0 | 15 | |
michael@0 | 16 | exports.testChromeSkin = function(assert, done) { |
michael@0 | 17 | let skinURL = 'chrome://test/skin/style.css'; |
michael@0 | 18 | |
michael@0 | 19 | Request({ |
michael@0 | 20 | url: skinURL, |
michael@0 | 21 | overrideMimeType: 'text/plain', |
michael@0 | 22 | onComplete: function (response) { |
michael@0 | 23 | assert.equal(response.text.trim(), 'test{}', 'chrome.manifest skin folder was registered!'); |
michael@0 | 24 | done(); |
michael@0 | 25 | } |
michael@0 | 26 | }).get(); |
michael@0 | 27 | |
michael@0 | 28 | assert.pass('requesting ' + skinURL); |
michael@0 | 29 | } |
michael@0 | 30 | |
michael@0 | 31 | exports.testChromeContent = function(assert, done) { |
michael@0 | 32 | let wt = WindowTracker({ |
michael@0 | 33 | onTrack: function(window) { |
michael@0 | 34 | if (window.document.documentElement.getAttribute('windowtype') === 'test:window') { |
michael@0 | 35 | assert.pass('test xul window was opened'); |
michael@0 | 36 | wt.unload(); |
michael@0 | 37 | |
michael@0 | 38 | close(window).then(done, assert.fail); |
michael@0 | 39 | } |
michael@0 | 40 | } |
michael@0 | 41 | }); |
michael@0 | 42 | |
michael@0 | 43 | open(XUL_URL).then( |
michael@0 | 44 | assert.pass.bind(assert, 'opened ' + XUL_URL), |
michael@0 | 45 | assert.fail); |
michael@0 | 46 | |
michael@0 | 47 | assert.pass('opening ' + XUL_URL); |
michael@0 | 48 | } |
michael@0 | 49 | |
michael@0 | 50 | exports.testChromeLocale = function(assert) { |
michael@0 | 51 | let jpLocalePath = Cc['@mozilla.org/chrome/chrome-registry;1']. |
michael@0 | 52 | getService(Ci.nsIChromeRegistry). |
michael@0 | 53 | convertChromeURL(NetUtil.newURI('chrome://test/locale/description.properties')). |
michael@0 | 54 | spec.replace(/(en\-US|ja\-JP)/, 'ja-JP'); |
michael@0 | 55 | let enLocalePath = jpLocalePath.replace(/ja\-JP/, 'en-US'); |
michael@0 | 56 | |
michael@0 | 57 | let jpStringBundle = Services.strings.createBundle(jpLocalePath); |
michael@0 | 58 | assert.equal(jpStringBundle.GetStringFromName('test'), |
michael@0 | 59 | 'ใในใ', |
michael@0 | 60 | 'locales ja-JP folder was copied correctly'); |
michael@0 | 61 | |
michael@0 | 62 | let enStringBundle = Services.strings.createBundle(enLocalePath); |
michael@0 | 63 | assert.equal(enStringBundle.GetStringFromName('test'), |
michael@0 | 64 | 'Test', |
michael@0 | 65 | 'locales en-US folder was copied correctly'); |
michael@0 | 66 | } |
michael@0 | 67 | |
michael@0 | 68 | require('sdk/test/runner').runTestsFromModule(module); |