Skip to content

Playwright is a framework for Web Testing and Automation. It allows testing Chromium, Firefox and WebKit with a single API.

chore: remove PLAYWRIGHT_INPUT_FILE_TEXTBOX (#36281)

Dmitry Gozman3c248ed163ff
diff --git a/packages/injected/src/ariaSnapshot.ts b/packages/injected/src/ariaSnapshot.ts
index a75a5cd185..c1f2ab4bdc 100644
--- a/packages/injected/src/ariaSnapshot.ts
+++ b/packages/injected/src/ariaSnapshot.ts
@@ -16,7 +16,7 @@
import { escapeRegExp, longestCommonSubstring, normalizeWhiteSpace } from '@isomorphic/stringUtils';
-import { box, getElementComputedStyle, getGlobalOptions, isElementVisible } from './domUtils';
+import { box, getElementComputedStyle, isElementVisible } from './domUtils';
import * as roleUtils from './roleUtils';
import { yamlEscapeKeyIfNeeded, yamlEscapeValueIfNeeded } from './yaml';
@@ -214,7 +214,7 @@ function toAriaNode(element: Element, options?: { forAI?: boolean, refPrefix?: s
result.selected = roleUtils.getAriaSelected(element);
if (element instanceof HTMLInputElement || element instanceof HTMLTextAreaElement) {
- if (element.type !== 'checkbox' && element.type !== 'radio' && (element.type !== 'file' || getGlobalOptions().inputFileRoleTextbox))
+ if (element.type !== 'checkbox' && element.type !== 'radio' && element.type !== 'file')
result.children = [element.value];
}
diff --git a/packages/injected/src/domUtils.ts b/packages/injected/src/domUtils.ts
index eb97e04a8b..e11d647694 100644
--- a/packages/injected/src/domUtils.ts
+++ b/packages/injected/src/domUtils.ts
@@ -16,7 +16,6 @@
type GlobalOptions = {
browserNameForWorkarounds?: string;
- inputFileRoleTextbox?: boolean;
};
let globalOptions: GlobalOptions = {};
export function setGlobalOptions(options: GlobalOptions) {
diff --git a/packages/injected/src/injectedScript.ts b/packages/injected/src/injectedScript.ts
index 05a1c9eb97..5155204e2b 100644
--- a/packages/injected/src/injectedScript.ts
+++ b/packages/injected/src/injectedScript.ts
@@ -73,7 +73,6 @@ export type InjectedScriptOptions = {
testIdAttributeName: string;
stableRafCount: number;
browserName: string;
- inputFileRoleTextbox: boolean;
customEngines: { name: string, source: string }[];
};
@@ -236,7 +235,7 @@ export class InjectedScript {
this._stableRafCount = options.stableRafCount;
this._browserName = options.browserName;
- setGlobalOptions({ browserNameForWorkarounds: options.browserName, inputFileRoleTextbox: options.inputFileRoleTextbox });
+ setGlobalOptions({ browserNameForWorkarounds: options.browserName });
this._setupGlobalListenersRemovalDetection();
this._setupHitTargetInterceptors();
diff --git a/packages/injected/src/roleUtils.ts b/packages/injected/src/roleUtils.ts
index b9bdd333a0..139b26bb63 100644
--- a/packages/injected/src/roleUtils.ts
+++ b/packages/injected/src/roleUtils.ts
@@ -16,7 +16,7 @@
import * as css from '@isomorphic/cssTokenizer';
-import { getGlobalOptions, closestCrossShadow, elementSafeTagName, enclosingShadowRootOrDocument, getElementComputedStyle, isElementStyleVisibilityVisible, isVisibleTextNode, parentElementOrShadowHost } from './domUtils';
+import { closestCrossShadow, elementSafeTagName, enclosingShadowRootOrDocument, getElementComputedStyle, isElementStyleVisibilityVisible, isVisibleTextNode, parentElementOrShadowHost } from './domUtils';
import type { AriaRole } from '@isomorphic/ariaSnapshot';
@@ -135,7 +135,7 @@ const kImplicitRoleByTagName: { [tagName: string]: (e: Element) => AriaRole | nu
// File inputs do not have a role by the spec: https://www.w3.org/TR/html-aam-1.0/#el-input-file.
// However, there are open issues about fixing it: https://github.com/w3c/aria/issues/1926.
// All browsers report it as a button, and it is rendered as a button, so we do "button".
- if (type === 'file' && !getGlobalOptions().inputFileRoleTextbox)
+ if (type === 'file')
return 'button';
return inputTypeToRole[type] || 'textbox';
},
@@ -707,7 +707,7 @@ function getTextAlternativeInternal(element: Element, options: AccessibleNameOpt
// There is no spec for this, but Chromium/WebKit do "Choose File" so we follow that.
// All browsers respect labels, aria-labelledby and aria-label.
// No browsers respect the title attribute, although w3c accname tests disagree. We follow browsers.
- if (!getGlobalOptions().inputFileRoleTextbox && tagName === 'INPUT' && (element as HTMLInputElement).type === 'file') {
+ if (tagName === 'INPUT' && (element as HTMLInputElement).type === 'file') {
options.visitedElements.add(element);
const labels = (element as HTMLInputElement).labels || [];
if (labels.length && !options.embeddedInLabelledBy)
diff --git a/packages/playwright-core/src/server/dom.ts b/packages/playwright-core/src/server/dom.ts
index ed7cb37cef..c2f422b864 100644
--- a/packages/playwright-core/src/server/dom.ts
+++ b/packages/playwright-core/src/server/dom.ts
@@ -94,7 +94,6 @@ export class FrameExecutionContext extends js.ExecutionContext {
testIdAttributeName: selectorsRegistry.testIdAttributeName(),
stableRafCount: this.frame._page.delegate.rafCountForStablePosition(),
browserName: this.frame._page.browserContext._browser.options.name,
- inputFileRoleTextbox: process.env.PLAYWRIGHT_INPUT_FILE_TEXTBOX ? true : false,
customEngines,
};
const source = `
diff --git a/packages/trace-viewer/src/ui/snapshotTab.tsx b/packages/trace-viewer/src/ui/snapshotTab.tsx
index 77c25164b9..bfef4840d6 100644
--- a/packages/trace-viewer/src/ui/snapshotTab.tsx
+++ b/packages/trace-viewer/src/ui/snapshotTab.tsx
@@ -77,7 +77,7 @@ export const SnapshotTabsView: React.FunctionComponent<{
<ToolbarButton icon='link-external' title='Open snapshot in a new tab' disabled={!snapshotUrls?.popoutUrl} onClick={() => {
const win = window.open(snapshotUrls?.popoutUrl || '', '_blank');
win?.addEventListener('DOMContentLoaded', () => {
- const injectedScript = new InjectedScript(win as any, { isUnderTest, sdkLanguage, testIdAttributeName, stableRafCount: 1, browserName: 'chromium', inputFileRoleTextbox: false, customEngines: [] });
+ const injectedScript = new InjectedScript(win as any, { isUnderTest, sdkLanguage, testIdAttributeName, stableRafCount: 1, browserName: 'chromium', customEngines: [] });
injectedScript.consoleApi.install();
});
}} />
@@ -284,7 +284,7 @@ function createRecorders(recorders: { recorder: Recorder, frameSelector: string
return;
const win = frameWindow as any;
if (!win._recorder && force) {
- const injectedScript = new InjectedScript(frameWindow as any, { isUnderTest, sdkLanguage, testIdAttributeName, stableRafCount: 1, browserName: 'chromium', inputFileRoleTextbox: false, customEngines: [] });
+ const injectedScript = new InjectedScript(frameWindow as any, { isUnderTest, sdkLanguage, testIdAttributeName, stableRafCount: 1, browserName: 'chromium', customEngines: [] });
const recorder = new Recorder(injectedScript);
win._injectedScript = injectedScript;
win._recorder = { recorder, frameSelector: parentFrameSelector };