Skip to content
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

Clipboard API: use bless() instead #37098

Closed
wants to merge 8 commits into from
Closed

Conversation

marcoscaceres
Copy link
Contributor

Replaces waitForUserActivation() for test_driver.bless(). They functionally do the same thing, but bless is better for devices where an actual clickable thing needs to be activated.

@foolip
Copy link
Member

foolip commented Jan 30, 2023

@marcoscaceres looking at the test results here, it looks like 3 tests have gone missing:
https://wpt.fyi/results/clipboard-apis?diff&filter=ADC&run_id=5200303578677248&run_id=4800456115617792

The same can be seen for Chrome and Firefox. Can you check what might be going on with this?

@marcoscaceres
Copy link
Contributor Author

Let's see if the strange missing tests situation corrects itself... not sure why that would happen.

@marcoscaceres
Copy link
Contributor Author

@saschanaz, hopefully better now 🙈

Copy link
Member

@saschanaz saschanaz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe check why lint failed tho.

@marcoscaceres
Copy link
Contributor Author

Hehe, I like letting the bots do the work🤖 will check, don’t worry.

Copy link
Member

@saschanaz saschanaz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmmm wpt.fyi results show regressions for all browsers, can you check that too?

@saschanaz
Copy link
Member

(You might want to keep the load event listener inside the current waitForUserActivation?)

@garykac
Copy link
Member

garykac commented May 28, 2024

Why not just replace the implementation of waitForUserActivation() with a call to test_driver.bless()?

waitForUserActivation is far more readable in the test - how many people know that test_driver.bless() means the test waits for user activation? I know I wasn't aware of that.

See also saschanaz's comment, since keeping waitForUserActivation would make it easier to keep the 'load' listener, and also add workarounds if in the future we find a scenario where bless() doesn't quite do what we need.

@marcoscaceres
Copy link
Contributor Author

Why not just replace the implementation of waitForUserActivation() with a call to test_driver.bless()?

That adds additional layers of indirection: test ➡️ user-activation.js ➡️ test_driver...

waitForUserActivation is far more readable in the test - how many people know that test_driver.bless() means the test waits for user activation? I know I wasn't aware of that.

Right, but it's the same problem with .waitForUserActivation(): it could (was) be doing the unnecessary things. Using test_driver.bless() gives us single place (single thing to learn), and any updates to it will also benefit these tests. It reduces complexity and duplication.

I know I wasn't aware of that.

I understand. That should have been caught in review (and it's part of all of us learning what the test_driver API provides). This was caught because it then goes into WebKit's review.

See also saschanaz's comment, since keeping waitForUserActivation would make it easier to keep the 'load' listener, and also add workarounds if in the future we find a scenario where bless() doesn't quite do what we need.

Right, but we should only use something like waitForUserActivation() in cases where bless() doesn't do what we need.

The load listener might be a more general issue with the test design, which we hopefully shouldn't need at all. I'll take a look.

@marcoscaceres
Copy link
Contributor Author

Ok, so, noting that bless() supports user activation within iframes. The load was using the wait for load on the iframes, but it's less racy to just set that explicitly. I've updated the tests to do that...

}
});
</script>
</html>
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't need this... there's no matching head one either.

@marcoscaceres marcoscaceres requested a review from saschanaz May 29, 2024 05:47
@marcoscaceres
Copy link
Contributor Author

@saschanaz, @garykac, let me know what you think! Hopefully this captures the intent better.

await new Promise(resolve => {
iframe.onload = resolve;
iframe.src = 'about:blank';
});
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm? Are we sure loading about:blank is synchronous everywhere? The existing wait code in waitForUserActivation is better IMO.

And we probably should still have a helper function for this.

const iframeClipboard = iframe.contentWindow.navigator.clipboard;
const blobInput = new Blob(['test string'], {type: 'text/plain'});
const clipboardItemInput = new ClipboardItem({'text/plain': blobInput});
await waitForUserActivation();
await test_driver.bless("clipboard", null, iframe.contentWindow);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wouldn't this change the test behavior here? Previously it clicked the parent page and now this clicks the iframe. wpt.fyi reports no change though.

And should the intent argument be passed consistently?

@marcoscaceres
Copy link
Contributor Author

Ok, closing this as I'm not getting time to go through them properly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants