- (void)willOpenMenu:(NSMenu *)menu withEvent:(NSEvent *)event;
- (void)didCloseMenu:(NSMenu *)menu withEvent:(NSEvent *)event;
-- (NSMenu *)actionMenu;
+- (NSMenu *)_actionMenu;
- (void)copy:(id)sender;
@end
{
__block bool didFinishSequence = false;
- NSMenu *actionMenu = self.actionMenu;
+ NSMenu *actionMenu = self._actionMenu;
RetainPtr<NSEvent> event = [NSEvent mouseEventWithType:NSLeftMouseDown location:point modifierFlags:0 timestamp:0 windowNumber:self.window.windowNumber context:0 eventNumber:0 clickCount:0 pressure:0];
dispatch_async(dispatch_get_main_queue(), ^{
[wkView runMenuSequenceAtPoint:windowPointForTarget(TargetType::Word) preDidCloseMenuHandler:^() {
EXPECT_EQ(kWKActionMenuReadOnlyText, [wkView _actionMenuResult].type);
EXPECT_WK_STREQ(@"word", retrieveSelection([wkView pageRef]));
- performMenuItemAtIndexOfTypeAsync([wkView actionMenu], 0, kWKContextActionItemTagCopyText);
+ performMenuItemAtIndexOfTypeAsync([wkView _actionMenu], 0, kWKContextActionItemTagCopyText);
EXPECT_WK_STREQ(@"word", watchPasteboardForString());
}];
[wkView runMenuSequenceAtPoint:windowPointForTarget(TargetType::Phrase) preDidCloseMenuHandler:^() {
EXPECT_EQ(kWKActionMenuReadOnlyText, [wkView _actionMenuResult].type);
EXPECT_WK_STREQ(@"New York", retrieveSelection([wkView pageRef]));
- performMenuItemAtIndexOfTypeAsync([wkView actionMenu], 0, kWKContextActionItemTagCopyText);
+ performMenuItemAtIndexOfTypeAsync([wkView _actionMenu], 0, kWKContextActionItemTagCopyText);
EXPECT_WK_STREQ(@"New York", watchPasteboardForString());
}];
[wkView runMenuSequenceAtPoint:windowPointForTarget(TargetType::ContentEditableWords) preDidCloseMenuHandler:^() {
EXPECT_EQ(kWKActionMenuEditableText, [wkView _actionMenuResult].type);
EXPECT_WK_STREQ(@"editable", retrieveSelection([wkView pageRef]));
- performMenuItemAtIndexOfTypeAsync([wkView actionMenu], 0, kWKContextActionItemTagCopyText);
+ performMenuItemAtIndexOfTypeAsync([wkView _actionMenu], 0, kWKContextActionItemTagCopyText);
EXPECT_WK_STREQ(@"editable", watchPasteboardForString());
}];
[wkView runMenuSequenceAtPoint:windowPointForTarget(TargetType::ContentEditablePhrase) preDidCloseMenuHandler:^() {
EXPECT_EQ(kWKActionMenuEditableText, [wkView _actionMenuResult].type);
EXPECT_WK_STREQ(@"New York", retrieveSelection([wkView pageRef]));
- performMenuItemAtIndexOfTypeAsync([wkView actionMenu], 0, kWKContextActionItemTagCopyText);
+ performMenuItemAtIndexOfTypeAsync([wkView _actionMenu], 0, kWKContextActionItemTagCopyText);
EXPECT_WK_STREQ(@"New York", watchPasteboardForString());
}];
[[NSPasteboard generalPasteboard] clearContents];
[[NSPasteboard generalPasteboard] setString:@"pasted string" forType:NSPasteboardTypeString];
EXPECT_WK_STREQ(@"editable", retrieveSelection([wkView pageRef]));
- performMenuItemAtIndexOfTypeAsync([wkView actionMenu], 2, kWKContextActionItemTagPaste);
+ performMenuItemAtIndexOfTypeAsync([wkView _actionMenu], 2, kWKContextActionItemTagPaste);
// Now check and see if our paste succeeded. It should only replace one 'editable'.
watchEditableAreaForString([wkView pageRef], "editable1", "pasted string editable editable editable");
[[NSPasteboard generalPasteboard] clearContents];
[[NSPasteboard generalPasteboard] setString:@"pasted over phrase" forType:NSPasteboardTypeString];
EXPECT_WK_STREQ(@"New York", retrieveSelection([wkView pageRef]));
- performMenuItemAtIndexOfTypeAsync([wkView actionMenu], 2, kWKContextActionItemTagPaste);
+ performMenuItemAtIndexOfTypeAsync([wkView _actionMenu], 2, kWKContextActionItemTagPaste);
// Now check and see if our paste succeeded, and replaced the whole phrase.
watchEditableAreaForString([wkView pageRef], "editable2", "pasted over phrase some words");
[wkView runMenuSequenceAtPoint:windowPointForTarget(TargetType::TextInputWords) preDidCloseMenuHandler:^() {
EXPECT_EQ(kWKActionMenuEditableText, [wkView _actionMenuResult].type);
EXPECT_WK_STREQ(@"editable", retrieveSelectionInElement([wkView pageRef], "input1"));
- performMenuItemAtIndexOfTypeAsync([wkView actionMenu], 0, kWKContextActionItemTagCopyText);
+ performMenuItemAtIndexOfTypeAsync([wkView _actionMenu], 0, kWKContextActionItemTagCopyText);
EXPECT_WK_STREQ(@"editable", watchPasteboardForString());
}];
[wkView runMenuSequenceAtPoint:windowPointForTarget(TargetType::TextInputPhrase) preDidCloseMenuHandler:^() {
EXPECT_EQ(kWKActionMenuEditableText, [wkView _actionMenuResult].type);
EXPECT_WK_STREQ(@"New York", retrieveSelectionInElement([wkView pageRef], "input2"));
- performMenuItemAtIndexOfTypeAsync([wkView actionMenu], 0, kWKContextActionItemTagCopyText);
+ performMenuItemAtIndexOfTypeAsync([wkView _actionMenu], 0, kWKContextActionItemTagCopyText);
EXPECT_WK_STREQ(@"New York", watchPasteboardForString());
}];
[[NSPasteboard generalPasteboard] clearContents];
[[NSPasteboard generalPasteboard] setString:@"pasted string" forType:NSPasteboardTypeString];
EXPECT_WK_STREQ(@"editable", retrieveSelectionInElement([wkView pageRef], "input1"));
- performMenuItemAtIndexOfTypeAsync([wkView actionMenu], 2, kWKContextActionItemTagPaste);
+ performMenuItemAtIndexOfTypeAsync([wkView _actionMenu], 2, kWKContextActionItemTagPaste);
// Now check and see if our paste succeeded. It should only replace one 'editable'.
watchEditableAreaForString([wkView pageRef], "input1", "pasted string editable editable editable");
[[NSPasteboard generalPasteboard] clearContents];
[[NSPasteboard generalPasteboard] setString:@"pasted over phrase" forType:NSPasteboardTypeString];
EXPECT_WK_STREQ(@"New York", retrieveSelectionInElement([wkView pageRef], "input2"));
- performMenuItemAtIndexOfTypeAsync([wkView actionMenu], 2, kWKContextActionItemTagPaste);
+ performMenuItemAtIndexOfTypeAsync([wkView _actionMenu], 2, kWKContextActionItemTagPaste);
// Now check and see if our paste succeeded, and replaced the whole phrase.
watchEditableAreaForString([wkView pageRef], "input2", "pasted over phrase some words");
[wkView runMenuSequenceAtPoint:windowPointForTarget(TargetType::TextAreaWords) preDidCloseMenuHandler:^() {
EXPECT_EQ(kWKActionMenuEditableText, [wkView _actionMenuResult].type);
EXPECT_WK_STREQ(@"editable", retrieveSelectionInElement([wkView pageRef], "textarea1"));
- performMenuItemAtIndexOfTypeAsync([wkView actionMenu], 0, kWKContextActionItemTagCopyText);
+ performMenuItemAtIndexOfTypeAsync([wkView _actionMenu], 0, kWKContextActionItemTagCopyText);
EXPECT_WK_STREQ(@"editable", watchPasteboardForString());
}];
[wkView runMenuSequenceAtPoint:windowPointForTarget(TargetType::TextAreaPhrase) preDidCloseMenuHandler:^() {
EXPECT_EQ(kWKActionMenuEditableText, [wkView _actionMenuResult].type);
EXPECT_WK_STREQ(@"New York", retrieveSelectionInElement([wkView pageRef], "textarea2"));
- performMenuItemAtIndexOfTypeAsync([wkView actionMenu], 0, kWKContextActionItemTagCopyText);
+ performMenuItemAtIndexOfTypeAsync([wkView _actionMenu], 0, kWKContextActionItemTagCopyText);
EXPECT_WK_STREQ(@"New York", watchPasteboardForString());
}];
[[NSPasteboard generalPasteboard] clearContents];
[[NSPasteboard generalPasteboard] setString:@"pasted" forType:NSPasteboardTypeString];
EXPECT_WK_STREQ(@"editable", retrieveSelectionInElement([wkView pageRef], "textarea1"));
- performMenuItemAtIndexOfTypeAsync([wkView actionMenu], 2, kWKContextActionItemTagPaste);
+ performMenuItemAtIndexOfTypeAsync([wkView _actionMenu], 2, kWKContextActionItemTagPaste);
// Now check and see if our paste succeeded. It should only replace one 'editable'.
watchEditableAreaForString([wkView pageRef], "textarea1", "pasted editable editable editable");
[[NSPasteboard generalPasteboard] clearContents];
[[NSPasteboard generalPasteboard] setString:@"pasted over phrase" forType:NSPasteboardTypeString];
EXPECT_WK_STREQ(@"New York", retrieveSelectionInElement([wkView pageRef], "textarea2"));
- performMenuItemAtIndexOfTypeAsync([wkView actionMenu], 2, kWKContextActionItemTagPaste);
+ performMenuItemAtIndexOfTypeAsync([wkView _actionMenu], 2, kWKContextActionItemTagPaste);
// Now check and see if our paste succeeded, and replaced the whole phrase.
watchEditableAreaForString([wkView pageRef], "textarea2", "pasted over phrase some words");
[wkView runMenuSequenceAtPoint:windowPointForTarget(TargetType::Image) preDidCloseMenuHandler:^() {
EXPECT_EQ(kWKActionMenuImage, [wkView _actionMenuResult].type);
- performMenuItemAtIndexOfTypeAsync([wkView actionMenu], 0, kWKContextActionItemTagCopyImage);
+ performMenuItemAtIndexOfTypeAsync([wkView _actionMenu], 0, kWKContextActionItemTagCopyImage);
NSImage *image = watchPasteboardForImage();
EXPECT_EQ(215, image.size.width);
EXPECT_EQ(kWKActionMenuImage, [wkView _actionMenuResult].type);
didFinishDownload = false;
- performMenuItemAtIndexOfTypeAsync([wkView actionMenu], 2, kWKContextActionItemTagSaveImageToDownloads);
+ performMenuItemAtIndexOfTypeAsync([wkView _actionMenu], 2, kWKContextActionItemTagSaveImageToDownloads);
Util::run(&didFinishDownload);
}];
activeDownloadContext.shouldCheckForImage = false;
[wkView runMenuSequenceAtPoint:windowPointForTarget(TargetType::Video) preDidCloseMenuHandler:^() {
EXPECT_EQ(kWKActionMenuVideo, [wkView _actionMenuResult].type);
- performMenuItemAtIndexOfTypeAsync([wkView actionMenu], 0, kWKContextActionItemTagCopyVideoURL);
+ performMenuItemAtIndexOfTypeAsync([wkView _actionMenu], 0, kWKContextActionItemTagCopyVideoURL);
NSString *videoURL = watchPasteboardForString();
EXPECT_WK_STREQ(@"test.mp4", [videoURL lastPathComponent]);
}];
[wkView runMenuSequenceAtPoint:windowPointForTarget(TargetType::MSEVideo) preDidCloseMenuHandler:^() {
EXPECT_EQ(kWKActionMenuVideo, [wkView _actionMenuResult].type);
- performMenuItemAtIndexOfTypeAsync([wkView actionMenu], 0, kWKContextActionItemTagCopyVideoURL);
+ performMenuItemAtIndexOfTypeAsync([wkView _actionMenu], 0, kWKContextActionItemTagCopyVideoURL);
NSString *videoURL = watchPasteboardForString();
EXPECT_WK_STREQ(@"action-menu-targets.html", [videoURL lastPathComponent]);
// Also, the download menu item should be disabled for non-downloadable video.
- ensureMenuItemAtIndexOfTypeIsDisabled([wkView actionMenu], 2, kWKContextActionItemTagSaveVideoToDownloads);
+ ensureMenuItemAtIndexOfTypeIsDisabled([wkView _actionMenu], 2, kWKContextActionItemTagSaveVideoToDownloads);
}];
// HTTP link.
RetainPtr<NSMenuItem> item = adoptNS([[NSMenuItem alloc] initWithTitle:@"Some Action" action:@selector(copy:) keyEquivalent:@""]);
[wkView _setOverrideActionMenuItems:@[ item.get() ]];
[wkView runMenuSequenceAtPoint:windowPointForTarget(TargetType::Image) preDidCloseMenuHandler:^() {
- EXPECT_EQ(1, [wkView actionMenu].numberOfItems);
- EXPECT_WK_STREQ(@"Some Action", [[wkView actionMenu] itemAtIndex:0].title);
+ EXPECT_EQ(1, [wkView _actionMenu].numberOfItems);
+ EXPECT_WK_STREQ(@"Some Action", [[wkView _actionMenu] itemAtIndex:0].title);
}];
[wkView _setOverrideActionMenuItems:nil];
// No menu should be built for whitespace (except in editable areas).
[wkView runMenuSequenceAtPoint:windowPointForTarget(TargetType::PageWhitespace) preDidCloseMenuHandler:^() {
EXPECT_EQ(kWKActionMenuNone, [wkView _actionMenuResult].type);
- EXPECT_EQ(0, [wkView actionMenu].numberOfItems);
+ EXPECT_EQ(0, [wkView _actionMenu].numberOfItems);
}];
}