Bug 236196

Summary: Adjust `platformResetStateToConsistentValues` to avoid grabbing the general pasteboard when possible
Product: WebKit Reporter: Wenson Hsieh <wenson_hsieh>
Component: Tools / TestsAssignee: Wenson Hsieh <wenson_hsieh>
Status: RESOLVED FIXED    
Severity: Normal CC: akeerthi, bdakin, darin, megan_gardner, ryanhaddad, thorton, webkit-bot-watchers-bugzilla, webkit-bug-importer
Priority: P2 Keywords: InRadar
Version: WebKit Nightly Build   
Hardware: Unspecified   
OS: Unspecified   
Attachments:
Description Flags
Patch none

Description Wenson Hsieh 2022-02-05 20:46:40 PST
Make it possible to work around rdar://86327357 by skipping layout tests that time out.
Comment 1 Wenson Hsieh 2022-02-05 21:06:36 PST
Created attachment 451024 [details]
Patch
Comment 2 Wenson Hsieh 2022-02-06 07:39:41 PST
Comment on attachment 451024 [details]
Patch

Thanks for the review!
Comment 3 EWS 2022-02-06 08:15:19 PST
Committed r289169 (246865@main): <https://commits.webkit.org/246865@main>

All reviewed patches have been landed. Closing bug and clearing flags on attachment 451024 [details].
Comment 4 Radar WebKit Bug Importer 2022-02-06 08:16:17 PST
<rdar://problem/88544615>
Comment 5 Alexey Proskuryakov 2022-02-06 11:40:54 PST
It's great to limit the damage like this.

Are the pasteboardChanged notifications synchronous? A little concerned if this adds more races to the execution.
Comment 6 Wenson Hsieh 2022-02-06 11:46:13 PST
(In reply to Alexey Proskuryakov from comment #5)
> It's great to limit the damage like this.
> 
> Are the pasteboardChanged notifications synchronous? A little concerned if
> this adds more races to the execution.

Indeed they are! (I verified this in a separate test app that calls `-[UIPasteboard setItemProviders:]` and listens for this notification, with logging statements):

```
- (void)viewDidLoad
{
    [super viewDidLoad];

    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(pasteboardChanged:) name:UIPasteboardChangedNotification object:nil];

    __auto_type pasteboard = [UIPasteboard generalPasteboard];
    __auto_type string = [[NSAttributedString alloc] initWithString:@"hello world"];
    __auto_type itemProvider = [[NSItemProvider alloc] initWithObject:string];

    NSLog(@"%@ change count before: %tu", pasteboard, pasteboard.changeCount);
    [pasteboard setItemProviders:@[ itemProvider ]];
    NSLog(@"%@ change count after: %tu", pasteboard, pasteboard.changeCount);
}

- (void)pasteboardChanged:(NSNotification *)notification
{
    NSLog(@"Pasteboard changed!");
}
```

with output:

```
UIPasteboardTest[25500:1935953] <_UIConcretePasteboard: 0x6000026604c0> change count before: 20398
UIPasteboardTest[25500:1935953] Pasteboard changed!
UIPasteboardTest[25500:1935953] <_UIConcretePasteboard: 0x6000026604c0> change count after: 20399
```