Skip to content

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

test(webkit): check the default drop effect derived from effectAllowed (#43477)

Yury Semikhatsky58b93301d906
diff --git a/tests/page/page-drag.spec.ts b/tests/page/page-drag.spec.ts
index c85018ca36..f2c8f7bbc8 100644
--- a/tests/page/page-drag.spec.ts
+++ b/tests/page/page-drag.spec.ts
@@ -175,7 +175,6 @@ it.describe('Drag and drop', () => {
});
it('DD-008 should respect the drop effect', async ({ page, browserName, isLinux, isMac, headless, trace }) => {
- it.fixme(browserName === 'webkit' && !isLinux, 'WebKit doesn\'t handle the drop effect correctly outside of linux.');
it.fixme(browserName === 'webkit' && isLinux && !headless, 'https://github.com/microsoft/playwright/issues/21646');
it.fixme(browserName === 'chromium' && !isMac && !headless, 'https://github.com/microsoft/playwright/issues/21646');
it.slow(trace === 'on');
@@ -228,6 +227,39 @@ it.describe('Drag and drop', () => {
return await page.evaluate('dropped');
}
});
+
+ it('DD-028 should report the default drop effect from effectAllowed', {
+ annotation: { type: 'issue', description: 'https://github.com/microsoft/playwright/issues/43447' },
+ }, async ({ page, browserName, isLinux, headless }) => {
+ it.fixme(browserName === 'webkit' && isLinux && !headless, 'https://github.com/microsoft/playwright/issues/21646');
+
+ await page.setContent(`
+ <div draggable="true">drag target</div>
+ <drop-target>this is the drop target</drop-target>
+ `);
+ await page.evaluate(() => {
+ window['dropEffect'] = 'none';
+
+ document.querySelector('div').addEventListener('dragstart', event => {
+ event.dataTransfer.effectAllowed = 'copyMove';
+ event.dataTransfer.setData('text/plain', 'drag data');
+ });
+ document.querySelector('div').addEventListener('dragend', event => {
+ window['dropEffect'] = event.dataTransfer.dropEffect;
+ });
+
+ // The target accepts the drag without setting dropEffect.
+ document.querySelector('drop-target').addEventListener('dragover', event => {
+ event.preventDefault();
+ });
+ });
+ await page.hover('div');
+ await page.mouse.down();
+ await page.hover('drop-target');
+ await page.mouse.up();
+ expect(await page.evaluate('dropEffect')).toBe('move');
+ });
+
it('DD-009 should work if the drag is canceled', async ({ page, server }) => {
await page.goto(server.PREFIX + '/drag-n-drop.html');
await page.evaluate(() => {
diff --git a/tests/registry.md b/tests/registry.md
index 02f43fc695..bacb1a8733 100644
--- a/tests/registry.md
+++ b/tests/registry.md
@@ -54,7 +54,7 @@ subsystem, add a row to the Subsystems table. Then update this file:
| `CV` | Coverage | `library/chromium/{js-coverage, css-coverage}`<br>`library/coverage` | 30 |
| `DB` | Debug | `library/{debugger, debug-controller}` | 22 |
| `DC` | Default (persistent) context | `library/{defaultbrowsercontext-1, defaultbrowsercontext-2}` | 42 |
-| `DD` | Drag and drop | `page/{page-drag, page-drop}` | 27 |
+| `DD` | Drag and drop | `page/{page-drag, page-drop}` | 28 |
| `DE` | Dispatch event | `page/page-dispatchevent` | 17 |
| `DI` | Dialog | `page/page-dialog` | 13 |
| `DO` | Download | `library/{download, downloads-path}` | 44 |
@@ -1656,6 +1656,7 @@ subsystem, add a row to the Subsystems table. Then update this file:
| `DD-025` | `page/page-drop.spec.ts` | should drop files and data together |
| `DD-026` | `page/page-drop.spec.ts` | should throw when target does not accept drop |
| `DD-027` | `page/page-drop.spec.ts` | should throw when neither files nor data provided |
+| `DD-028` | `page/page-drag.spec.ts` | Drag and drop › should report the default drop effect from effectAllowed |
### DE — Dispatch event