Skip to content

Commit

Permalink
Bug 1863867 - Add expriment targeting based on archiecture bits r=barret
Browse files Browse the repository at this point in the history
  • Loading branch information
PaulBone committed Dec 12, 2023
1 parent 011eb4b commit 62b5d50
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ Please note that some targeting attributes require stricter controls on the tele
* [activeNotifications](#activenotifications)
* [addonsInfo](#addonsinfo)
* [addressesSaved](#addressessaved)
* [archBits](#archbits)
* [attachedFxAOAuthClients](#attachedfxaoauthclients)
* [attributionData](#attributiondata)
* [backgroundTaskName](#backgroundtaskname)
Expand Down Expand Up @@ -588,6 +589,16 @@ addressesSaved > 1
declare const addressesSaved: Promise<number>
```
### `archBits`
The number of bits used to represent a pointer in this build.
#### Definition
```ts
declare const archBits: number;
```

### `xpinstallEnabled`

Pref used by system administrators to disallow add-ons from installed altogether.
Expand Down
13 changes: 13 additions & 0 deletions browser/components/newtab/lib/ASRouterTargeting.jsm
Original file line number Diff line number Diff line change
Expand Up @@ -1012,6 +1012,19 @@ const TargetingGetters = {
height: window?.screen.availHeight,
};
},

get archBits() {
let bits = null;
try {
bits = Services.sysinfo.getProperty("archbits", null);
} catch (_e) {
// getProperty can throw if the memsize does not exist
}
if (bits) {
bits = Number(bits);
}
return bits;
},
};

const ASRouterTargeting = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1693,3 +1693,9 @@ add_task(async function check_primaryResolution() {
"Height property should return a number"
);
});

add_task(async function check_archBits() {
const bits = ASRouterTargeting.Environment.archBits;
is(typeof bits, "number", "archBits should be a number");
ok(bits === 32 || bits === 64, "archBits is either 32 or 64");
});
6 changes: 6 additions & 0 deletions xpcom/base/nsSystemInfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -974,6 +974,12 @@ nsresult nsSystemInfo::Init() {
SetUint64Property(u"memsize"_ns, PR_GetPhysicalMemorySize());
SetUint32Property(u"umask"_ns, nsSystemInfo::gUserUmask);

#ifdef HAVE_64BIT_BUILD
SetUint32Property(u"archbits"_ns, 64);
#else
SetUint32Property(u"archbits"_ns, 32);
#endif

uint64_t virtualMem = 0;

#if defined(XP_WIN)
Expand Down

0 comments on commit 62b5d50

Please sign in to comment.