Skip to content

Commit 877b25a

Browse files
committed
Backed out changeset f7c78cadff5d (bug 1830725) for causing bc failures on browser_AttributionCode_telemetry.js.
1 parent 6f0fefb commit 877b25a

File tree

5 files changed

+143
-294
lines changed

5 files changed

+143
-294
lines changed

browser/components/attribution/AttributionCode.sys.mjs

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -64,12 +64,10 @@ export var AttributionCode = {
6464
* Wrapper to pull campaign IDs from MSIX builds.
6565
* This function solely exists to make it easy to mock out for tests.
6666
*/
67-
async msixCampaignId() {
68-
const windowsPackageManager = Cc[
69-
"@mozilla.org/windows-package-manager;1"
70-
].createInstance(Ci.nsIWindowsPackageManager);
71-
72-
return windowsPackageManager.campaignId();
67+
get msixCampaignId() {
68+
return Cc["@mozilla.org/windows-package-manager;1"]
69+
.createInstance(Ci.nsIWindowsPackageManager)
70+
.getCampaignId();
7371
},
7472

7573
/**
@@ -348,7 +346,7 @@ export var AttributionCode = {
348346
)}`
349347
);
350348
let encoder = new TextEncoder();
351-
bytes = encoder.encode(encodeURIComponent(await this.msixCampaignId()));
349+
bytes = encoder.encode(encodeURIComponent(this.msixCampaignId));
352350
} else {
353351
bytes = await AttributionIOUtils.read(attributionFile.path);
354352
}

browser/components/attribution/test/browser/browser_AttributionCode_telemetry.js

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -80,17 +80,9 @@ add_task(async function test_read_error() {
8080
throw new Error("read_error");
8181
};
8282

83-
// On MSIX builds, AttributionIOUtils.read is not used; AttributionIOUtils.msixCampaignId is.
84-
// Ensure we override that as well.
85-
let oldMsixCampaignId = AttributionIOUtils.msixCampaignId;
86-
AttributionIOUtils.msixCampaignId = async () => {
87-
throw new Error("read_error");
88-
};
89-
9083
registerCleanupFunction(() => {
9184
AttributionIOUtils.exists = oldExists;
9285
AttributionIOUtils.read = oldRead;
93-
AttributionIOUtils.msixCampaignId = oldMsixCampaignId;
9486
});
9587

9688
// Try to read the file

browser/components/attribution/test/xpcshell/test_AttributionCode.js

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,6 @@ add_task(async () => {
2020
* to make sure we reject bad ones and accept good ones.
2121
*/
2222
add_task(async function testValidAttrCodes() {
23-
let msixCampaignIdStub = sinon.stub(AttributionCode, "msixCampaignId");
24-
2523
let currentCode = null;
2624
for (let entry of validAttrCodes) {
2725
currentCode = entry.code;
@@ -38,32 +36,28 @@ add_task(async function testValidAttrCodes() {
3836
// In real life, the attribution codes returned from Microsoft APIs
3937
// are not URI encoded, and the AttributionCode code that deals with
4038
// them expects that - so we have to simulate that as well.
41-
msixCampaignIdStub.callsFake(async () => decodeURIComponent(currentCode));
39+
sinon
40+
.stub(AttributionCode, "msixCampaignId")
41+
.get(() => decodeURIComponent(currentCode));
4242
} else {
4343
await AttributionCode.writeAttributionFile(currentCode);
4444
}
4545
AttributionCode._clearCache();
4646
let result = await AttributionCode.getAttrDataAsync();
47-
4847
Assert.deepEqual(
4948
result,
5049
entry.parsed,
5150
"Parsed code should match expected value, code was: " + currentCode
5251
);
5352
}
5453
AttributionCode._clearCache();
55-
56-
// Restore the msixCampaignId stub so that other tests don't fail stubbing it
57-
msixCampaignIdStub.restore();
5854
});
5955

6056
/**
6157
* Make sure codes with various formatting errors are not seen as valid.
6258
*/
6359
add_task(async function testInvalidAttrCodes() {
64-
let msixCampaignIdStub = sinon.stub(AttributionCode, "msixCampaignId");
6560
let currentCode = null;
66-
6761
for (let code of invalidAttrCodes) {
6862
currentCode = code;
6963

@@ -79,7 +73,9 @@ add_task(async function testInvalidAttrCodes() {
7973
continue;
8074
}
8175

82-
msixCampaignIdStub.callsFake(async () => decodeURIComponent(currentCode));
76+
sinon
77+
.stub(AttributionCode, "msixCampaignId")
78+
.get(() => decodeURIComponent(currentCode));
8379
} else {
8480
await AttributionCode.writeAttributionFile(currentCode);
8581
}
@@ -92,9 +88,6 @@ add_task(async function testInvalidAttrCodes() {
9288
);
9389
}
9490
AttributionCode._clearCache();
95-
96-
// Restore the msixCampaignId stub so that other tests don't fail stubbing it
97-
msixCampaignIdStub.restore();
9891
});
9992

10093
/**

toolkit/system/windowsPackageManager/nsIWindowsPackageManager.idl

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ interface nsIWindowsPackageManager : nsISupports
2323
*/
2424
unsigned long long getInstalledDate();
2525

26-
/* Asynchronously retrieves the campaignId, if any, a user's Microsoft Store install is
26+
/* Retrieves the campaignId, if any, a user's Microsoft Store install is
2727
* associated with. These are present if the user clicked a "ms-window-store://"
2828
* or "https://" link that included a "cid" query argument the very first time
2929
* they installed the app. (This value appears to be cached forever, so
@@ -37,6 +37,5 @@ interface nsIWindowsPackageManager : nsISupports
3737
* a non-packaged build.
3838
* @throw NS_ERROR_FAILURE for any other errors
3939
*/
40-
[implicit_jscontext]
41-
Promise campaignId();
40+
AString getCampaignId();
4241
};

0 commit comments

Comments
 (0)