browser/metro/base/tests/mochitest/browser_inputsource.js

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/browser/metro/base/tests/mochitest/browser_inputsource.js	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,50 @@
     1.4 +// -*- Mode: js2; tab-width: 2; indent-tabs-mode: nil; js2-basic-offset: 2; js2-skip-preprocessor-directives: t; -*-
     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 +"use strict";
    1.10 +
    1.11 +/*=============================================================================
    1.12 +  Test cases
    1.13 +=============================================================================*/
    1.14 +
    1.15 +function test() {
    1.16 +  runTests();
    1.17 +}
    1.18 +
    1.19 +function setUp() {
    1.20 +  yield addTab("about:blank");
    1.21 +}
    1.22 +
    1.23 +function testState(aState) {
    1.24 +  let bcastValue = document.getElementById("bcast_preciseInput").getAttribute("input");
    1.25 +  is(bcastValue, aState, "bcast attribute is " + aState);
    1.26 +
    1.27 +  if (aState == "precise") {
    1.28 +    ok(InputSourceHelper.isPrecise, "InputSourceHelper");
    1.29 +    let uri = Util.makeURI("chrome://browser/content/cursor.css");
    1.30 +    ok(!StyleSheetSvc.sheetRegistered(uri, Ci.nsIStyleSheetService.AGENT_SHEET), "cursor stylesheet registered");
    1.31 +  } else {
    1.32 +    ok(!InputSourceHelper.isPrecise, "InputSourceHelper");
    1.33 +    let uri = Util.makeURI("chrome://browser/content/cursor.css");
    1.34 +    ok(StyleSheetSvc.sheetRegistered(uri, Ci.nsIStyleSheetService.AGENT_SHEET), "cursor stylesheet registered");
    1.35 +  }
    1.36 +}
    1.37 +
    1.38 +
    1.39 +gTests.push({
    1.40 +  desc: "precise/imprecise input switcher",
    1.41 +  setUp: setUp,
    1.42 +  run: function () {
    1.43 +    notifyPrecise();
    1.44 +    testState("precise");
    1.45 +    notifyImprecise();
    1.46 +    testState("imprecise");
    1.47 +    notifyPrecise();
    1.48 +    testState("precise");
    1.49 +    notifyImprecise();
    1.50 +    testState("imprecise");
    1.51 +  }
    1.52 +});
    1.53 +

mercurial