dom/tests/browser/browser_bug1004814.js

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/dom/tests/browser/browser_bug1004814.js	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,46 @@
     1.4 +/* vim:set ts=2 sw=2 sts=2 et: */
     1.5 +/* This Source Code Form is subject to the terms of the Mozilla Public
     1.6 + * License, v. 2.0. If a copy of the MPL was not distributed with this
     1.7 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
     1.8 +
     1.9 +const TEST_URI = "http://example.com/browser/dom/tests/browser/test_bug1004814.html";
    1.10 +
    1.11 +function test() {
    1.12 +  waitForExplicitFinish();
    1.13 +
    1.14 +  ConsoleObserver.init();
    1.15 +
    1.16 +  var tab = gBrowser.addTab(TEST_URI);
    1.17 +  gBrowser.selectedTab = tab;
    1.18 +
    1.19 +  registerCleanupFunction(function () {
    1.20 +    gBrowser.removeTab(tab);
    1.21 +  });
    1.22 +}
    1.23 +
    1.24 +var ConsoleObserver = {
    1.25 +  QueryInterface: XPCOMUtils.generateQI([Ci.nsIObserver]),
    1.26 +
    1.27 +  init: function() {
    1.28 +    Services.obs.addObserver(this, "console-api-log-event", false);
    1.29 +  },
    1.30 +
    1.31 +  destroy: function() {
    1.32 +    Services.obs.removeObserver(this, "console-api-log-event");
    1.33 +  },
    1.34 +
    1.35 +  observe: function(aSubject, aTopic, aData) {
    1.36 +    var obj = aSubject.wrappedJSObject;
    1.37 +    if (obj.arguments.length != 1 || obj.arguments[0] != 'bug1004814' ||
    1.38 +        obj.level != 'timeEnd') {
    1.39 +      return;
    1.40 +    }
    1.41 +
    1.42 +    ok("timer" in obj, "ConsoleEvent contains 'timer' property");
    1.43 +    ok("duration" in obj.timer, "ConsoleEvent.timer contains 'duration' property");
    1.44 +    ok(obj.timer.duration > 0, "ConsoleEvent.timer.duration > 0: " + obj.timer.duration + " ~ 200ms");
    1.45 +
    1.46 +    this.destroy();
    1.47 +    finish();
    1.48 +  }
    1.49 +};

mercurial