addon-sdk/source/test/test-module.js

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/addon-sdk/source/test/test-module.js	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,37 @@
     1.4 +/* This Source Code Form is subject to the terms of the Mozilla Public
     1.5 + * License, v. 2.0. If a copy of the MPL was not distributed with this
     1.6 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
     1.7 +
     1.8 +"use strict";
     1.9 +
    1.10 +/** Disabled because of Bug 672199
    1.11 +exports["test module exports are frozen"] = function(assert) {
    1.12 +  assert.ok(Object.isFrozen(require("sdk/hotkeys")),
    1.13 +            "module exports are frozen");
    1.14 +};
    1.15 +
    1.16 +exports["test redefine exported property"] = function(assert) {
    1.17 +  let hotkeys = require("sdk/hotkeys");
    1.18 +  let { Hotkey } = hotkeys;
    1.19 +  try { Object.defineProperty(hotkeys, 'Hotkey', { value: {} }); } catch(e) {}
    1.20 +  assert.equal(hotkeys.Hotkey, Hotkey, "exports can't be redefined");
    1.21 +};
    1.22 +*/
    1.23 +
    1.24 +exports["test can't delete exported property"] = function(assert) {
    1.25 +  let hotkeys = require("sdk/hotkeys");
    1.26 +  let { Hotkey } = hotkeys;
    1.27 +
    1.28 +  try { delete hotkeys.Hotkey; } catch(e) {}
    1.29 +  assert.equal(hotkeys.Hotkey, Hotkey, "exports can't be deleted");
    1.30 +};
    1.31 +
    1.32 +exports["test can't override exported property"] = function(assert) {
    1.33 +  let hotkeys = require("sdk/hotkeys");
    1.34 +  let { Hotkey } = hotkeys;
    1.35 +
    1.36 +  try { hotkeys.Hotkey = Object } catch(e) {}
    1.37 +  assert.equal(hotkeys.Hotkey, Hotkey, "exports can't be overriden");
    1.38 +};
    1.39 +
    1.40 +require("test").run(exports);

mercurial