OLD | NEW |
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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 #include "config.h" | 5 #include "config.h" |
6 | 6 |
7 #include "testing/gtest/include/gtest/gtest.h" | 7 #include "testing/gtest/include/gtest/gtest.h" |
8 | 8 |
9 #include "base/file_util.h" | 9 #include "base/file_util.h" |
10 #include "base/message_loop.h" | 10 #include "base/message_loop.h" |
(...skipping 13 matching lines...) Expand all Loading... |
24 } | 24 } |
25 }; | 25 }; |
26 | 26 |
27 TEST_F(BookmarkletTest, Redirect) { | 27 TEST_F(BookmarkletTest, Redirect) { |
28 test_shell_->LoadURL(L"javascript:location.href='data:text/plain,SUCCESS'"); | 28 test_shell_->LoadURL(L"javascript:location.href='data:text/plain,SUCCESS'"); |
29 test_shell_->WaitTestFinished(); | 29 test_shell_->WaitTestFinished(); |
30 std::wstring text = test_shell_->GetDocumentText(); | 30 std::wstring text = test_shell_->GetDocumentText(); |
31 EXPECT_EQ(L"SUCCESS", text); | 31 EXPECT_EQ(L"SUCCESS", text); |
32 } | 32 } |
33 | 33 |
| 34 TEST_F(BookmarkletTest, RedirectVoided) { |
| 35 // This test should be redundant with the Redirect test above. The point |
| 36 // here is to emphasize that in either case the assignment to location during |
| 37 // the evaluation of the script should suppress loading the script result. |
| 38 // Here, because of the void() wrapping there is no script result. |
| 39 test_shell_->LoadURL(L"javascript:void(location.href='data:text/plain,SUCCESS'
)"); |
| 40 test_shell_->WaitTestFinished(); |
| 41 std::wstring text = test_shell_->GetDocumentText(); |
| 42 EXPECT_EQ(L"SUCCESS", text); |
| 43 } |
| 44 |
34 TEST_F(BookmarkletTest, NonEmptyResult) { | 45 TEST_F(BookmarkletTest, NonEmptyResult) { |
35 std::wstring text; | 46 std::wstring text; |
36 | 47 |
37 // TODO(darin): This test fails in a JSC build. WebCore+JSC does not really | 48 // TODO(darin): This test fails in a JSC build. WebCore+JSC does not really |
38 // need to support this usage until WebCore supports javascript: URLs that | 49 // need to support this usage until WebCore supports javascript: URLs that |
39 // generate content (https://bugs.webkit.org/show_bug.cgi?id=14959). It is | 50 // generate content (https://bugs.webkit.org/show_bug.cgi?id=14959). It is |
40 // important to note that Safari does not support bookmarklets, and this is | 51 // important to note that Safari does not support bookmarklets, and this is |
41 // really an edge case. Our behavior with V8 is consistent with FF and IE. | 52 // really an edge case. Our behavior with V8 is consistent with FF and IE. |
42 #if 0 | 53 #if 0 |
43 test_shell_->LoadURL(L"javascript:false"); | 54 test_shell_->LoadURL(L"javascript:false"); |
(...skipping 12 matching lines...) Expand all Loading... |
56 test_shell_->LoadURL( | 67 test_shell_->LoadURL( |
57 L"javascript:document.open();" | 68 L"javascript:document.open();" |
58 L"document.write('hello world');" | 69 L"document.write('hello world');" |
59 L"document.close()"); | 70 L"document.close()"); |
60 MessageLoop::current()->RunAllPending(); | 71 MessageLoop::current()->RunAllPending(); |
61 std::wstring text = test_shell_->GetDocumentText(); | 72 std::wstring text = test_shell_->GetDocumentText(); |
62 EXPECT_EQ(L"hello world", text); | 73 EXPECT_EQ(L"hello world", text); |
63 } | 74 } |
64 | 75 |
65 } // namespace | 76 } // namespace |
OLD | NEW |