dom/inputmethod/mochitest/inputmethod_common.js

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/dom/inputmethod/mochitest/inputmethod_common.js	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,35 @@
     1.4 +function inputmethod_setup(callback) {
     1.5 +  SimpleTest.waitForExplicitFinish();
     1.6 +  SimpleTest.requestCompleteLog();
     1.7 +  let appInfo = SpecialPowers.Cc['@mozilla.org/xre/app-info;1']
     1.8 +                .getService(SpecialPowers.Ci.nsIXULAppInfo);
     1.9 +  if (appInfo.name != 'B2G') {
    1.10 +    SpecialPowers.Cu.import("resource://gre/modules/Keyboard.jsm", this);
    1.11 +  }
    1.12 +
    1.13 +  let permissions = [];
    1.14 +  ['input-manage', 'browser'].forEach(function(name) {
    1.15 +    permissions.push({
    1.16 +      type: name,
    1.17 +      allow: true,
    1.18 +      context: document
    1.19 +    });
    1.20 +  });
    1.21 +
    1.22 +  SpecialPowers.pushPermissions(permissions, function() {
    1.23 +    let prefs = [
    1.24 +      ['dom.mozBrowserFramesEnabled', true],
    1.25 +      // Enable navigator.mozInputMethod.
    1.26 +      ['dom.mozInputMethod.enabled', true],
    1.27 +      // Bypass the permission check for mozInputMethod API.
    1.28 +      ['dom.mozInputMethod.testing', true]
    1.29 +    ];
    1.30 +    SpecialPowers.pushPrefEnv({set: prefs}, function() {
    1.31 +      SimpleTest.waitForFocus(callback);
    1.32 +    });
    1.33 +  });
    1.34 +}
    1.35 +
    1.36 +function inputmethod_cleanup() {
    1.37 +  SimpleTest.finish();
    1.38 +}

mercurial