fune/browser/components/tests/unit/test_browserGlue_pingcentre.js
Victor Porof 1f830c96da Bug 1561435 - Format browser/components/, a=automatic-formatting
# ignore-this-changeset

Differential Revision: https://phabricator.services.mozilla.com/D36042

--HG--
extra : source : d3afcafdce650a6f36cebbc126ee93b17f13cf52
2019-07-05 09:53:32 +02:00

28 lines
823 B
JavaScript

const { PingCentre } = ChromeUtils.import("resource:///modules/PingCentre.jsm");
const TOPIC_SHIELD_INIT_COMPLETE = "shield-init-complete";
const SEND_PING_MOCK = sinon.stub(PingCentre.prototype, "sendPing");
let gBrowserGlue = Cc["@mozilla.org/browser/browserglue;1"].getService(
Ci.nsIObserver
);
add_task(async function() {
// Simulate ping centre sendPing() trigger.
gBrowserGlue.observe(null, TOPIC_SHIELD_INIT_COMPLETE, null);
const SEND_PING_CALL_ARGS = {
event: "AS_ENABLED",
value: 0,
};
const SEND_PING_FILTER = { filter: "activity-stream" };
Assert.ok(
SEND_PING_MOCK.called,
"gBrowserGlue.pingCentre.sendPing() is called"
);
Assert.ok(
SEND_PING_MOCK.calledWithExactly(SEND_PING_CALL_ARGS, SEND_PING_FILTER),
"sendPing() is called with the correct param"
);
});