feat(extension): report the channel beside the version (step 7)
CI / lint (push) Successful in 4s
CI / extension-version (push) Successful in 5s
CI / frontend-build (push) Successful in 20s
CI / backend-lint-and-test (push) Successful in 32s
extension / lint (push) Successful in 28s
CI / integration (push) Successful in 3m52s
Build images / sign-extension (push) Successful in 4s
Build images / build-ml (push) Failing after 5s
Build images / build-agent (push) Successful in 13s
Build images / build-web (push) Successful in 2m4s
CI / lint (push) Successful in 4s
CI / extension-version (push) Successful in 5s
CI / frontend-build (push) Successful in 20s
CI / backend-lint-and-test (push) Successful in 32s
extension / lint (push) Successful in 28s
CI / integration (push) Successful in 3m52s
Build images / sign-extension (push) Successful in 4s
Build images / build-ml (push) Failing after 5s
Build images / build-agent (push) Successful in 13s
Build images / build-web (push) Successful in 2m4s
Closes the half of the ask the signing work didn't: a way to tell a dev
build from a main one. FC_CHANNEL is baked into the web image at build
time and /api/extension/manifest reports it as its own key, next to
version — the popup banner, the toolbar tooltip and the Settings card all
name it.
Beside the version, never inside it. A `1.0.3499884-dev` suffix is the
obvious shortcut and it is the exact failure this design comes from:
versionIsNewer parses each dotted segment with parseInt, so a suffixed
segment reads as 0, every dev build compares equal to every other, and
"no update available" stops being distinguishable from "I cannot read this
version". The comparator already degrades rather than discarding (rule
150), which is a reason not to NEED the suffix, not a licence to add one.
Two tests hold the line — one backend, asserting version and channel are
separate keys; one frontend, asserting the rendered version text stays the
bare derived number.
Optional on the read side, and absent rather than defaulted. An image
built before this field says nothing by not having the key; an image built
without a channel now says nothing the same way, so there is one absence
to handle instead of a second spelling of "unknown". Every reader drops
the label entirely when it is missing and reads exactly as it did before.
Reported verbatim rather than validated against {dev, main}: if an image
declares something else, showing what it claims helps whoever is debugging
more than dropping it would.
FC_CHANNEL is declared LAST in the Dockerfile. An ARG invalidates every
layer below it, and this is the one value that differs between the dev and
main builds of identical source — earlier, and the two channels could
never share a cached pip install. A tag push counts as main: a vYY.MM.DD
tag is cut from main, so that image is a main-channel artifact wearing an
immutable name.
No channel switcher, deliberately. background.js:34 already records that
Firefox's static update_url cannot apply, because every FC instance is a
different host — so the extension asks its configured backend, and the
channel IS the instance it points at. Switching is repointing apiUrl and
reinstalling from that host. A separate setting would contradict each
server build shipping its own extension.
This commit touches packaged extension files, so it moves the derived
version and will sign a new one via AMO — the first push to exercise the
extension-changed path from dev end to end.
This commit is contained in:
@@ -383,6 +383,53 @@ async def test_extension_manifest_returns_metadata_when_xpi_present(client, monk
|
||||
assert body["sha256"] == hashlib.sha256(b"fake-xpi-content").hexdigest()
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_extension_manifest_reports_the_channel_the_image_declares(
|
||||
client, monkeypatch, tmp_path
|
||||
):
|
||||
"""The channel travels BESIDE the version, never inside it.
|
||||
|
||||
Folding it in as a `1.0.3499884-dev` suffix is the failure this design
|
||||
exists to avoid: the extension's comparator parses each dotted segment as
|
||||
an integer, so a suffixed segment collapses to 0 and every dev build
|
||||
compares equal to every other — "no update available" and "I cannot read
|
||||
this version" stop being distinguishable. Asserting the two are separate
|
||||
keys is what keeps a future edit from merging them.
|
||||
"""
|
||||
(tmp_path / "fabledcurator-1.2.3.xpi").write_bytes(b"x")
|
||||
monkeypatch.setattr(extension_module, "XPI_DIR", tmp_path)
|
||||
monkeypatch.setattr(extension_module, "FC_CHANNEL", "dev")
|
||||
resp = await client.get("/api/extension/manifest")
|
||||
assert resp.status_code == 200
|
||||
body = await resp.get_json()
|
||||
assert body["channel"] == "dev"
|
||||
assert body["version"] == "1.2.3"
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_extension_manifest_omits_the_channel_when_the_image_declares_none(
|
||||
client, monkeypatch, tmp_path
|
||||
):
|
||||
"""A local build, or any image from before the field existed.
|
||||
|
||||
The key must be ABSENT rather than present-and-empty: absence is the state
|
||||
every consumer already handles (an older image conveys it by not having the
|
||||
key at all), so a blank channel reuses that path instead of introducing a
|
||||
second spelling of "unknown" for each reader to special-case.
|
||||
"""
|
||||
(tmp_path / "fabledcurator-1.2.3.xpi").write_bytes(b"x")
|
||||
monkeypatch.setattr(extension_module, "XPI_DIR", tmp_path)
|
||||
monkeypatch.setattr(extension_module, "FC_CHANNEL", "")
|
||||
resp = await client.get("/api/extension/manifest")
|
||||
assert resp.status_code == 200
|
||||
body = await resp.get_json()
|
||||
assert "channel" not in body
|
||||
# Everything else still answers — an image with no channel is not a
|
||||
# degraded one, it just cannot say which channel it came from.
|
||||
assert body["installed"] is True
|
||||
assert body["latest_url"] == "/extension/fabledcurator-latest.xpi"
|
||||
|
||||
|
||||
# --- /extension/<filename> -----------------------------------------
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user