fune/browser/components/tests/unit/test_browserGlue_pingcentre.js
Nan Jiang ea55294f24 Bug 1458617 - Add telemetry to detect if a user has a custom about:newtab/home page. r=Mardak
MozReview-Commit-ID: JrGQmFb2AXH

--HG--
extra : rebase_source : 7259ff36962004632ec64195bb6803b83ebf67c9
2018-05-15 13:47:56 -04:00

22 lines
797 B
JavaScript

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");
});