| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #import "content/browser/web_contents/web_drag_source_mac.h" | 5 #import "content/browser/web_contents/web_drag_source_mac.h" |
| 6 | 6 |
| 7 #include "base/memory/ref_counted.h" |
| 7 #include "content/browser/web_contents/web_contents_impl.h" | 8 #include "content/browser/web_contents/web_contents_impl.h" |
| 8 #include "content/public/common/drop_data.h" | 9 #include "content/public/common/drop_data.h" |
| 9 #include "content/public/test/test_renderer_host.h" | 10 #include "content/public/test/test_renderer_host.h" |
| 10 #include "testing/gtest/include/gtest/gtest.h" | 11 #include "testing/gtest/include/gtest/gtest.h" |
| 12 #import "ui/base/clipboard/clipboard_util_mac.h" |
| 11 #include "url/gurl.h" | 13 #include "url/gurl.h" |
| 12 | 14 |
| 13 namespace content { | 15 namespace content { |
| 14 | 16 |
| 15 typedef RenderViewHostTestHarness WebDragSourceMacTest; | 17 typedef RenderViewHostTestHarness WebDragSourceMacTest; |
| 16 | 18 |
| 17 TEST_F(WebDragSourceMacTest, DragInvalidlyEscapedBookmarklet) { | 19 TEST_F(WebDragSourceMacTest, DragInvalidlyEscapedBookmarklet) { |
| 18 scoped_ptr<WebContents> contents(CreateTestWebContents()); | 20 scoped_ptr<WebContents> contents(CreateTestWebContents()); |
| 19 base::scoped_nsobject<NSView> view( | 21 base::scoped_nsobject<NSView> view( |
| 20 [[NSView alloc] initWithFrame:NSMakeRect(0, 0, 10, 10)]); | 22 [[NSView alloc] initWithFrame:NSMakeRect(0, 0, 10, 10)]); |
| 21 | 23 |
| 22 scoped_ptr<DropData> dropData(new DropData); | 24 scoped_ptr<DropData> dropData(new DropData); |
| 23 dropData->url = GURL("javascript:%"); | 25 dropData->url = GURL("javascript:%"); |
| 24 | 26 |
| 25 WebContentsImpl* contentsImpl = static_cast<WebContentsImpl*>(contents.get()); | 27 WebContentsImpl* contentsImpl = static_cast<WebContentsImpl*>(contents.get()); |
| 28 scoped_refptr<ui::UniquePasteboard> pasteboard1 = new ui::UniquePasteboard; |
| 26 base::scoped_nsobject<WebDragSource> source([[WebDragSource alloc] | 29 base::scoped_nsobject<WebDragSource> source([[WebDragSource alloc] |
| 27 initWithContents:contentsImpl | 30 initWithContents:contentsImpl |
| 28 view:view | 31 view:view |
| 29 dropData:dropData.get() | 32 dropData:dropData.get() |
| 30 image:nil | 33 image:nil |
| 31 offset:NSZeroPoint | 34 offset:NSZeroPoint |
| 32 pasteboard:[NSPasteboard pasteboardWithUniqueName] | 35 pasteboard:pasteboard1->get() |
| 33 dragOperationMask:NSDragOperationCopy]); | 36 dragOperationMask:NSDragOperationCopy]); |
| 34 | 37 |
| 35 // Test that this call doesn't throw any exceptions: http://crbug.com/128371 | 38 // Test that this call doesn't throw any exceptions: http://crbug.com/128371 |
| 36 base::scoped_nsobject<NSPasteboard> pasteboard( | 39 scoped_refptr<ui::UniquePasteboard> pasteboard2 = new ui::UniquePasteboard; |
| 37 [NSPasteboard pasteboardWithUniqueName]); | 40 [source lazyWriteToPasteboard:pasteboard2->get() forType:NSURLPboardType]; |
| 38 [source lazyWriteToPasteboard:pasteboard forType:NSURLPboardType]; | |
| 39 } | 41 } |
| 40 | 42 |
| 41 } // namespace content | 43 } // namespace content |
| OLD | NEW |