Skip to content

Commit

Permalink
Ignore incorrect nodoc in Chrome 111+ for world parameter
Browse files Browse the repository at this point in the history
  • Loading branch information
oliverdunk committed May 23, 2024
1 parent 180c029 commit 08cd3e7
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 2 deletions.
10 changes: 10 additions & 0 deletions tests/lib/override.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,16 @@ test('setPanelBehavior is visible', t => {
t.assert(rc.isVisible({ nodoc: true }, 'api:sidePanel.setPanelBehavior'));
});

test('version specific API is visible in correct versions', t => {
// Correctly marked as nodoc in Chrome 110. Should not be visible.
const rcNotVisible = new RenderOverride({}, new FeatureQuery({}), null, 110);
t.assert(!rcNotVisible.isVisible({ nodoc: true }, 'api:extensionTypes.ExecutionWorld'));

// Incorrectly marked as nodoc in Chrome 111. nodoc should be ignored.
const rcVisible = new RenderOverride({}, new FeatureQuery({}), null, 111);
t.assert(rcVisible.isVisible({ nodoc: true }, 'api:extensionTypes.ExecutionWorld'));
});

test('chrome-install-location tag is added', (t) => {
const rc = new RenderOverride({}, new FeatureQuery({'api:sidePanel.setPanelBehavior': { location: 'policy' }}), {
generated: "",
Expand Down
8 changes: 7 additions & 1 deletion tools/override.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,19 +76,22 @@ export class RenderOverride extends EmptyRenderOverride {
#fq;
#api;
#history;
#majorVersion;

/**
* @param {{[name: string]: chromeTypes.NamespaceSpec}} api
* @param {FeatureQuery} fq
* @param {chromeTypes.HistoricSymbolsPayload?} history
* @param {number?} majorVersion
*/
constructor(api, fq, history = null) {
constructor(api, fq, history = null, majorVersion = null) {
super();
const allNamespaceNames = Object.keys(api);
this.#commentRewriter = buildNamespaceAwareMarkdownRewrite(allNamespaceNames);
this.#fq = fq;
this.#api = api;
this.#history = history;
this.#majorVersion = majorVersion;
}

/**
Expand All @@ -114,6 +117,9 @@ export class RenderOverride extends EmptyRenderOverride {
}

switch (id) {
case 'api:extensionTypes.ExecutionWorld':
case 'api:contentScripts.ContentScript.world':
return !this.#majorVersion || this.#majorVersion >= 111;
case 'api:contextMenus.OnClickData':
case 'api:notifications.NotificationBitmap':
case 'api:sidePanel.getPanelBehavior':
Expand Down
4 changes: 3 additions & 1 deletion tools/render-symbols.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,10 @@ This is used internally to generate historic version data for Chrome's APIs.
/** @type {chromeTypes.ProcessedAPIData} */
const o = JSON.parse(await getStdin());

const majorVersion = o.version ? Math.ceil(+o.version.version.split(".")[0]) : undefined;

Check warning on line 62 in tools/render-symbols.js

View check run for this annotation

Codecov / codecov/patch

tools/render-symbols.js#L61-L62

Added lines #L61 - L62 were not covered by tests
const featureQuery = new FeatureQuery(o.feature);
const renderOverride = new RenderOverride(o.api, featureQuery);
const renderOverride = new RenderOverride(o.api, featureQuery, null, majorVersion);

Check warning on line 64 in tools/render-symbols.js

View check run for this annotation

Codecov / codecov/patch

tools/render-symbols.js#L64

Added line #L64 was not covered by tests
const renderContext = new RenderContext(renderOverride);

/** @type {Map<string, boolean>} */
Expand Down

0 comments on commit 08cd3e7

Please sign in to comment.