Skip to content

Commit

Permalink
✅ Add tests for pageActions I guess..?
Browse files Browse the repository at this point in the history
  • Loading branch information
trickypr committed Feb 11, 2024
1 parent a685208 commit 28da8a4
Show file tree
Hide file tree
Showing 20 changed files with 2,365 additions and 123 deletions.
13 changes: 12 additions & 1 deletion apps/content/src/browser/components/omnibox/PageAction.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,10 @@
</script>

<ToolbarButton
id={`page-action-icon--${pageAction.extensionId
.replace('@', '')
.replace('}', '')
.replace('{', '')}`}
kind="page-icon"
bind:button
on:click={handleClick}
Expand All @@ -130,7 +134,14 @@
</ToolbarButton>

{#if pageAction.popupUrl}
<xul:panel bind:this={panel} class="popup"></xul:panel>
<xul:panel
id={`page-action-panel--${pageAction.extensionId
.replace('@', '')
.replace('}', '')
.replace('{', '')}`}
bind:this={panel}
class="popup"
></xul:panel>
{/if}

<style>
Expand Down
2 changes: 2 additions & 0 deletions apps/content/src/shared/components/ToolbarButton.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,11 @@
export let button: HTMLButtonElement | undefined = undefined
export let kind: 'toolbar' | 'page-icon' = 'toolbar'
export let tooltip: string | undefined = undefined
export let id = ''
</script>

<button
{id}
class={`toolbar__button toolbar__button--${kind}`}
bind:this={button}
on:click
Expand Down
1 change: 0 additions & 1 deletion apps/content/src/shared/customizableUI/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -289,6 +289,5 @@ export const fromExportTypeStable = (component: ExportComponent) =>
fromExportTypeStableInternal('root')(component, 0)

export const customizableUIDynamicPref = dynamicStringPref((json) => {
console.log('test', json)
return fromExportTypeStable(JSON.parse(json) as ExportComponent)
})
7 changes: 1 addition & 6 deletions apps/content/static/gtests.html
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,7 @@ <h1>Test runner</h1>

// @ts-check
/// <reference types="@browser/link" />
console.log('start import')

console.log('import int')

console.log('call')
TestManager.call()
TestManager.report()
</script>
</body>
</html>
5 changes: 5 additions & 0 deletions apps/extensions/lib/ext-browser.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,10 @@
"scopes": ["addon_parent"],
"manifest": ["page_action"],
"paths": [["pageAction"]]
},
"tabs": {
"schema": "chrome://bextensions/content/schemas/tabs.json",
"scopes": ["addon_parent"],
"paths": [["tabs"]]
}
}
3 changes: 1 addition & 2 deletions apps/extensions/lib/parent/ext-pageAction.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ this.pageAction = class extends ExtensionAPIPersistent {
const options = extension.manifest.page_action

this.pageAction = new lazy.EPageActions.PageAction({
extensionId: extension.id,
tooltip: options.default_title,
popupUrl: options.default_popup,
showMatches: options.show_matches,
Expand Down Expand Up @@ -67,9 +68,7 @@ this.pageAction = class extends ExtensionAPIPersistent {
*/
onClicked({ fire }) {
const callback = async (_name, clickInfo) => {
console.log(fire, fire.wakeup, !!fire.wakeup)
if (fire.wakeup) await fire.wakeup()
console.log('fire')
fire.sync(clickInfo)
}

Expand Down
9 changes: 9 additions & 0 deletions apps/extensions/lib/parent/ext-tabs.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
// @ts-check
/// <reference path="../types/index.d.ts" />

this.tabs = class extends ExtensionAPIPersistent {
/**
* @param {BaseContext} context
*/
getAPI(context) {}
}
Loading

0 comments on commit 28da8a4

Please sign in to comment.