-
Notifications
You must be signed in to change notification settings - Fork 45
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
initial version of an install and uninstall hook #778
Changes from all commits
38c4e76
a047c88
3d76fa4
43ea147
2e0006a
46c1612
3133ba0
ff13dad
0e42728
2bedd04
4a222ab
dbb2b5a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,6 +12,46 @@ add_task(withDriver(Assert, async function uuids(driver) { | |
isnot(uuid1, uuid2, "uuids are unique"); | ||
})); | ||
|
||
add_task(withDriver(Assert, async function installXpi(driver) { | ||
// Test that we can install an XPI from any URL | ||
const dir = getChromeDir(getResolvedURI(gTestPath)); | ||
dir.append("fixtures"); | ||
dir.append("normandy.xpi"); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can you check with someone more up-to-date with this stuff (than me) - maybe @Mossop - how this works with add-on signature checks? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If normandy.xpi is unsigned then this will only work in automation in Firefox 55 and higher. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @Mossop normandy.xpi was indeed unsigned.. I've updated the xpi so that it's signed now. |
||
const xpiUrl = Services.io.newFileURI(dir).spec; | ||
var addonId = await driver.installAddon(xpiUrl); | ||
is(addonId, "normandydriver@example.com", "Expected test addon was installed"); | ||
isnot(addonId, null, "Addon install was successful"); | ||
|
||
// Installing kicks off an asychronous process which tries to read the manifest.json | ||
// to startup the addon. Note that onInstallEnded is triggered too early | ||
// which is why we need this delay. | ||
await new Promise(resolve => SimpleTest.executeSoon(resolve)); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should we wait for something specific, e.g. an observer notification generated by the test add-on once install has actually happened? Otherwise this feels like it's waiting to go intermittent on infra... There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. More generally, it feels odd that the addon manager doesn't provide something 'better' to wait for, where install is 'properly' finished, instead of only sort of... Maybe @Mossop can suggest something? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think this is really a problem with |
||
|
||
const uninstallMsg = await driver.uninstallAddon(addonId); | ||
is(uninstallMsg, null, `Uninstall returned an unexpected message [${uninstallMsg}]`); | ||
})); | ||
|
||
add_task(withDriver(Assert, async function uninstallInvalidAddonId(driver) { | ||
const invalidAddonId = "not_a_valid_xpi_id@foo.bar"; | ||
try { | ||
await driver.uninstallAddon(invalidAddonId); | ||
ok(false, `Uninstalling an invalid XPI should fail. uninstallAddon resolved successfully though.`); | ||
} catch (e) { | ||
ok(true, `This is the expected failure`); | ||
} | ||
})); | ||
|
||
|
||
add_task(withDriver(Assert, async function installXpiBadURL(driver) { | ||
const xpiUrl = "file:///tmp/invalid_xpi.xpi"; | ||
try { | ||
await driver.installAddon(xpiUrl); | ||
ok(false, "Installation succeeded on an XPI that doesn't exist"); | ||
} catch (reason) { | ||
ok(true, `Installation was rejected: [${reason}]`); | ||
} | ||
})); | ||
|
||
add_task(withDriver(Assert, async function userId(driver) { | ||
// Test that userId is a UUID | ||
ok(UUID_REGEX.test(driver.userId), "userId is a uuid"); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
{ | ||
"manifest_version": 2, | ||
"name": "normandy_fixture", | ||
"version": "1.0", | ||
"description": "Dummy test fixture that's a webextension", | ||
"applications": { | ||
"gecko": { | ||
"id": "normandydriver@example.com" | ||
} | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No need to bother returning anything here.