fune/toolkit/modules/tests/browser/browser_PromiseMessage.js
Kris Maglione 918ed6c474 Bug 1431533: Part 5a - Auto-rewrite code to use ChromeUtils import methods. r=florian
This was done using the following script:
37e3803c7a/processors/chromeutils-import.jsm

MozReview-Commit-ID: 1Nc3XDu0wGl

--HG--
extra : source : 12fc4dee861c812fd2bd032c63ef17af61800c70
extra : intermediate-source : 34c999fa006bffe8705cf50c54708aa21a962e62
extra : histedit_source : b2be2c5e5d226e6c347312456a6ae339c1e634b0
2018-01-29 15:20:18 -08:00

38 lines
1.3 KiB
JavaScript

/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
/* global Cu, BrowserTestUtils, is, ok, add_task, gBrowser */
"use strict";
ChromeUtils.import("resource://gre/modules/PromiseMessage.jsm", this);
const url = "http://example.org/tests/dom/manifest/test/resource.sjs";
/**
* Test basic API error conditions
*/
add_task(async function() {
await BrowserTestUtils.withNewTab({gBrowser, url}, testPromiseMessageAPI);
});
async function testPromiseMessageAPI(aBrowser) {
// Reusing an existing message.
const msgKey = "DOM:WebManifest:hasManifestLink";
const mm = aBrowser.messageManager;
const id = "this should not change";
const foo = "neitherShouldThis";
const data = {id, foo};
// This just returns false, and it doesn't matter for this test.
await PromiseMessage.send(mm, msgKey, data);
// Check that no new props were added
const props = Object.getOwnPropertyNames(data);
ok(props.length === 2, "There should only be 2 props");
ok(props.includes("id"), "Has the id property");
ok(props.includes("foo"), "Has the foo property");
// Check that the props didn't change.
is(data.id, id, "The id prop must not change.");
is(data.foo, foo, "The foo prop must not change.");
}