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 3// found in the LICENSE file. 4 5#include <string> 6 7#include "base/file_util.h" 8#include "base/string_util.h" 9#include "third_party/WebKit/Source/WebKit/chromium/public/WebDataSource.h" 10#include "third_party/WebKit/Source/WebKit/chromium/public/WebFrame.h" 11#include "third_party/WebKit/Source/WebKit/chromium/public/WebString.h" 12#include "third_party/WebKit/Source/WebKit/chromium/public/WebURL.h" 13#include "third_party/WebKit/Source/WebKit/chromium/public/WebVector.h" 14#include "third_party/WebKit/Source/WebKit/chromium/public/WebView.h" 15#include "webkit/glue/webkit_glue.h" 16#include "webkit/tools/test_shell/test_shell_test.h" 17 18using WebKit::WebDataSource; 19using WebKit::WebFrame; 20using WebKit::WebString; 21using WebKit::WebURL; 22using WebKit::WebVector; 23 24typedef TestShellTest IFrameRedirectTest; 25 26// Tests that loading a page in an iframe from javascript results in 27// a redirect from about:blank. 28TEST_F(IFrameRedirectTest, Test) { 29 FilePath iframes_data_dir_ = data_dir_; 30 iframes_data_dir_ = iframes_data_dir_.AppendASCII("test_shell"); 31 iframes_data_dir_ = iframes_data_dir_.AppendASCII("iframe_redirect"); 32 ASSERT_TRUE(file_util::PathExists(iframes_data_dir_)); 33 34 GURL test_url = GetTestURL(iframes_data_dir_, "main.html"); 35 36 test_shell_->LoadURL(test_url); 37 test_shell_->WaitTestFinished(); 38 39 WebFrame* iframe = 40 test_shell_->webView()->findFrameByName(WebString::fromUTF8("ifr")); 41 ASSERT_TRUE(iframe != NULL); 42 WebDataSource* iframe_ds = iframe->dataSource(); 43 ASSERT_TRUE(iframe_ds != NULL); 44 WebVector<WebURL> redirects; 45 iframe_ds->redirectChain(redirects); 46 ASSERT_FALSE(redirects.isEmpty()); 47 ASSERT_TRUE(GURL(redirects[0]) == GURL("about:blank")); 48} 49