browser_bug1004814.js (1438B)
1 /* vim:set ts=2 sw=2 sts=2 et: */ 2 /* This Source Code Form is subject to the terms of the Mozilla Public 3 * License, v. 2.0. If a copy of the MPL was not distributed with this 4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 5 6 add_task(async function () { 7 const TEST_URI = 8 "http://example.com/browser/dom/tests/browser/test_bug1004814.html"; 9 10 await BrowserTestUtils.withNewTab(TEST_URI, async aBrowser => { 11 let duration = await SpecialPowers.spawn(aBrowser, [], function () { 12 const ConsoleAPIStorage = Cc[ 13 "@mozilla.org/consoleAPI-storage;1" 14 ].getService(Ci.nsIConsoleAPIStorage); 15 16 return new Promise(resolve => { 17 function observe(aSubject) { 18 var obj = aSubject.wrappedJSObject; 19 if ( 20 obj.arguments.length != 1 || 21 obj.arguments[0] != "bug1004814" || 22 obj.level != "timeEnd" 23 ) { 24 return; 25 } 26 27 ConsoleAPIStorage.removeLogEventListener(observe); 28 resolve(obj.timer.duration); 29 } 30 31 ConsoleAPIStorage.addLogEventListener( 32 observe, 33 Cc["@mozilla.org/systemprincipal;1"].createInstance(Ci.nsIPrincipal) 34 ); 35 36 var w = new content.Worker("worker_bug1004814.js"); 37 w.postMessage(true); 38 }); 39 }); 40 41 Assert.greater( 42 duration, 43 0, 44 "ConsoleEvent.timer.duration > 0: " + duration + " ~ 200ms" 45 ); 46 }); 47 });