dom/tests/browser/browser_bug1004814.js

Tue, 06 Jan 2015 21:39:09 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Tue, 06 Jan 2015 21:39:09 +0100
branch
TOR_BUG_9701
changeset 8
97036ab72558
permissions
-rw-r--r--

Conditionally force memory storage according to privacy.thirdparty.isolate;
This solves Tor bug #9701, complying with disk avoidance documented in
https://www.torproject.org/projects/torbrowser/design/#disk-avoidance.

michael@0 1 /* vim:set ts=2 sw=2 sts=2 et: */
michael@0 2 /* This Source Code Form is subject to the terms of the Mozilla Public
michael@0 3 * License, v. 2.0. If a copy of the MPL was not distributed with this
michael@0 4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
michael@0 5
michael@0 6 const TEST_URI = "http://example.com/browser/dom/tests/browser/test_bug1004814.html";
michael@0 7
michael@0 8 function test() {
michael@0 9 waitForExplicitFinish();
michael@0 10
michael@0 11 ConsoleObserver.init();
michael@0 12
michael@0 13 var tab = gBrowser.addTab(TEST_URI);
michael@0 14 gBrowser.selectedTab = tab;
michael@0 15
michael@0 16 registerCleanupFunction(function () {
michael@0 17 gBrowser.removeTab(tab);
michael@0 18 });
michael@0 19 }
michael@0 20
michael@0 21 var ConsoleObserver = {
michael@0 22 QueryInterface: XPCOMUtils.generateQI([Ci.nsIObserver]),
michael@0 23
michael@0 24 init: function() {
michael@0 25 Services.obs.addObserver(this, "console-api-log-event", false);
michael@0 26 },
michael@0 27
michael@0 28 destroy: function() {
michael@0 29 Services.obs.removeObserver(this, "console-api-log-event");
michael@0 30 },
michael@0 31
michael@0 32 observe: function(aSubject, aTopic, aData) {
michael@0 33 var obj = aSubject.wrappedJSObject;
michael@0 34 if (obj.arguments.length != 1 || obj.arguments[0] != 'bug1004814' ||
michael@0 35 obj.level != 'timeEnd') {
michael@0 36 return;
michael@0 37 }
michael@0 38
michael@0 39 ok("timer" in obj, "ConsoleEvent contains 'timer' property");
michael@0 40 ok("duration" in obj.timer, "ConsoleEvent.timer contains 'duration' property");
michael@0 41 ok(obj.timer.duration > 0, "ConsoleEvent.timer.duration > 0: " + obj.timer.duration + " ~ 200ms");
michael@0 42
michael@0 43 this.destroy();
michael@0 44 finish();
michael@0 45 }
michael@0 46 };

mercurial