dom/tests/browser/browser_bug1004814.js

changeset 0
6474c204b198
equal deleted inserted replaced
-1:000000000000 0:e36e93426668
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 const TEST_URI = "http://example.com/browser/dom/tests/browser/test_bug1004814.html";
7
8 function test() {
9 waitForExplicitFinish();
10
11 ConsoleObserver.init();
12
13 var tab = gBrowser.addTab(TEST_URI);
14 gBrowser.selectedTab = tab;
15
16 registerCleanupFunction(function () {
17 gBrowser.removeTab(tab);
18 });
19 }
20
21 var ConsoleObserver = {
22 QueryInterface: XPCOMUtils.generateQI([Ci.nsIObserver]),
23
24 init: function() {
25 Services.obs.addObserver(this, "console-api-log-event", false);
26 },
27
28 destroy: function() {
29 Services.obs.removeObserver(this, "console-api-log-event");
30 },
31
32 observe: function(aSubject, aTopic, aData) {
33 var obj = aSubject.wrappedJSObject;
34 if (obj.arguments.length != 1 || obj.arguments[0] != 'bug1004814' ||
35 obj.level != 'timeEnd') {
36 return;
37 }
38
39 ok("timer" in obj, "ConsoleEvent contains 'timer' property");
40 ok("duration" in obj.timer, "ConsoleEvent.timer contains 'duration' property");
41 ok(obj.timer.duration > 0, "ConsoleEvent.timer.duration > 0: " + obj.timer.duration + " ~ 200ms");
42
43 this.destroy();
44 finish();
45 }
46 };

mercurial