Changeset 83366 in webkit
- Timestamp:
- Apr 8, 2011 5:54:36 PM (13 years ago)
- Location:
- trunk/Source/WebKit/chromium
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebKit/chromium/ChangeLog
r83353 r83366 1 2011-04-08 Aaron Boodman <aa@chromium.org> 2 3 Reviewed by Dmitry Titov. 4 5 Re-land http://trac.webkit.org/changeset/83007. This works 6 without changes after https://bugs.webkit.org/show_bug.cgi?id=58110. 7 8 https://bugs.webkit.org/show_bug.cgi?id=58096 9 10 * WebKit.gyp: 11 * WebKit.gypi: 12 * public/WebFrame.h: 13 * src/WebFrameImpl.cpp: 14 (WebKit::WebFrame::frameForContext): 15 * tests/WebFrameTest.cpp: 16 (WebKit::WebFrameTest::WebFrameTest): 17 (WebKit::WebFrameTest::registerMockedURLLoad): 18 (WebKit::WebFrameTest::loadFrame): 19 (WebKit::TEST_F): 20 1 21 2011-04-08 Daniel Cheng <dcheng@chromium.org> 2 22 -
trunk/Source/WebKit/chromium/WebKit.gyp
r83284 r83366 825 825 ['OS=="win"', { 826 826 'sources': [ 827 # FIXME: Port PopupMenuTest and WebFrameTestto Linux and Mac.827 # FIXME: Port PopupMenuTest to Linux and Mac. 828 828 'tests/PopupMenuTest.cpp', 829 829 'tests/TransparencyWinTest.cpp', 830 830 'tests/UniscribeHelperTest.cpp', 831 'tests/WebFrameTest.cpp',832 831 'tests/WebPageSerializerTest.cpp', 833 832 ], -
trunk/Source/WebKit/chromium/WebKit.gypi
r83249 r83366 67 67 'tests/TreeTestHelpers.cpp', 68 68 'tests/TreeTestHelpers.h', 69 'tests/WebFrameTest.cpp', 69 70 ], 70 71 }, -
trunk/Source/WebKit/chromium/public/WebFrame.h
r83320 r83366 99 99 WEBKIT_API static WebFrame* frameForCurrentContext(); 100 100 101 #if WEBKIT_USING_V8 102 // Returns the frame corresponding to the given context. This can return 0 103 // if the context is detached from the frame, or if the context doesn't 104 // correspond to a frame (e.g., workers). 105 WEBKIT_API static WebFrame* frameForContext(v8::Handle<v8::Context>); 106 #endif 107 101 108 // Returns the frame inside a given frame or iframe element. Returns 0 if 102 109 // the given element is not a frame, iframe or if the frame is empty. -
trunk/Source/WebKit/chromium/src/WebFrameImpl.cpp
r83320 r83366 477 477 } 478 478 479 #if WEBKIT_USING_V8 480 WebFrame* WebFrame::frameForContext(v8::Handle<v8::Context> context) 481 { 482 return WebFrameImpl::fromFrame(V8Proxy::retrieveFrame(context)); 483 } 484 #endif 485 479 486 WebFrame* WebFrame::fromFrameOwnerElement(const WebElement& element) 480 487 { -
trunk/Source/WebKit/chromium/tests/WebFrameTest.cpp
r83021 r83366 36 36 #include "WebFrame.h" 37 37 #include "WebFrameClient.h" 38 #include "WebSettings.h" 38 39 #include "WebString.h" 39 40 #include "WebURL.h" … … 41 42 #include "WebURLResponse.h" 42 43 #include "WebView.h" 44 #include "v8.h" 43 45 44 46 using namespace WebKit; … … 48 50 class WebFrameTest : public testing::Test { 49 51 public: 50 WebFrameTest() {} 52 WebFrameTest() 53 : baseURL("http://www.test.com/") 54 { 55 } 51 56 52 57 virtual void TearDown() … … 55 60 } 56 61 57 void registerMockedURLLoad(const WebURL& url, const WebURLResponse& response, const WebString& fileName)62 void registerMockedURLLoad(const std::string& fileName) 58 63 { 64 WebURLResponse response; 65 response.initialize(); 66 response.setMIMEType("text/html"); 67 59 68 std::string filePath = webkit_support::GetWebKitRootDir().utf8(); 60 filePath.append("/Source/WebKit/chromium/tests/data/"); 61 filePath.append(fileName.utf8()); 62 webkit_support::RegisterMockedURL(url, response, WebString::fromUTF8(filePath)); 69 filePath += "/Source/WebKit/chromium/tests/data/"; 70 filePath += fileName; 71 72 webkit_support::RegisterMockedURL(WebURL(GURL(baseURL + fileName)), response, WebString::fromUTF8(filePath)); 63 73 } 64 74 … … 67 77 webkit_support::ServeAsynchronousMockedRequests(); 68 78 } 79 80 void loadFrame(WebFrame* frame, const std::string& fileName) 81 { 82 WebURLRequest urlRequest; 83 urlRequest.initialize(); 84 urlRequest.setURL(WebURL(GURL(baseURL + fileName))); 85 frame->loadRequest(urlRequest); 86 } 87 88 protected: 89 std::string baseURL; 69 90 }; 70 91 … … 74 95 TEST_F(WebFrameTest, ContentText) 75 96 { 76 // Register our resources. 77 WebURLResponse response; 78 response.initialize(); 79 response.setMIMEType("text/html"); 80 std::string rootURL = "http://www.test.com/"; 81 const char* files[] = { "iframes_test.html", "visible_iframe.html", 82 "invisible_iframe.html", "zero_sized_iframe.html" }; 83 for (int i = 0; i < (sizeof(files) / sizeof(char*)); ++i) { 84 WebURL webURL = GURL(rootURL + files[i]); 85 registerMockedURLLoad(webURL, response, WebString::fromUTF8(files[i])); 86 } 97 registerMockedURLLoad("iframes_test.html"); 98 registerMockedURLLoad("visible_iframe.html"); 99 registerMockedURLLoad("invisible_iframe.html"); 100 registerMockedURLLoad("zero_sized_iframe.html"); 87 101 88 // Create and initialize the WebView. 102 // Create and initialize the WebView. 89 103 TestWebFrameClient webFrameClient; 90 104 WebView* webView = WebView::create(0); 91 105 webView->initializeMainFrame(&webFrameClient); 92 106 93 // Load the main frame URL. 94 WebURL testURL(GURL(rootURL + files[0])); 95 WebURLRequest urlRequest; 96 urlRequest.initialize(); 97 urlRequest.setURL(testURL); 98 webView->mainFrame()->loadRequest(urlRequest); 99 100 // Load all pending asynchronous requests. 107 loadFrame(webView->mainFrame(), "iframes_test.html"); 101 108 serveRequests(); 102 109 … … 112 119 } 113 120 121 TEST_F(WebFrameTest, FrameForEnteredContext) 122 { 123 registerMockedURLLoad("iframes_test.html"); 124 registerMockedURLLoad("visible_iframe.html"); 125 registerMockedURLLoad("invisible_iframe.html"); 126 registerMockedURLLoad("zero_sized_iframe.html"); 127 128 // Create and initialize the WebView. 129 TestWebFrameClient webFrameClient; 130 WebView* webView = WebView::create(0); 131 webView->settings()->setJavaScriptEnabled(true); 132 webView->initializeMainFrame(&webFrameClient); 133 134 loadFrame(webView->mainFrame(), "iframes_test.html"); 135 serveRequests(); 136 137 v8::HandleScope scope; 138 EXPECT_EQ(webView->mainFrame(), 139 WebFrame::frameForContext( 140 webView->mainFrame()->mainWorldScriptContext())); 141 EXPECT_EQ(webView->mainFrame()->firstChild(), 142 WebFrame::frameForContext( 143 webView->mainFrame()->firstChild()->mainWorldScriptContext())); 144 145 webView->close(); 114 146 } 147 148 }
Note: See TracChangeset
for help on using the changeset viewer.