TEST_F(WebPageSerializerTest, fromUrlWithMinusMinus) { WebURL topFrameURL = toKURL("http://www.test.com?--x--"); registerMockedURLLoad(topFrameURL.spec(), WebString::fromUTF8("text_only_page.html")); loadURLInTopFrame(topFrameURL); SimpleWebPageSerializerClient serializerClient; WebVector<WebURL> links(&topFrameURL, 1); WebVector<WebString> localPaths(&"local", 1); WebPageSerializer::serialize(webView()->mainFrame()->toWebLocalFrame(), &serializerClient, links, localPaths, ""); EXPECT_EQ("<!-- saved from url=(0030)http://www.test.com/?-%2Dx-%2D -->", serializerClient.toString().substr(1, 60)); }
void TestShell::showDevTools() { if (!m_devTools) { WebURL url = webkit_support::GetDevToolsPathAsURL(); if (!url.isValid()) { ASSERT(false); return; } m_devTools = createNewWindow(url); ASSERT(m_devTools); createDRTDevToolsClient(m_drtDevToolsAgent.get()); } m_devTools->show(WebKit::WebNavigationPolicyNewWindow); }
void TestShell::showDevTools() { if (!m_devTools) { WebURL url = webkit_support::GetDevToolsPathAsURL(); if (!url.isValid()) { ASSERT(false); return; } m_devTools = createNewWindow(url); m_devTools->webView()->settings()->setMemoryInfoEnabled(true); m_devTools->setLogConsoleOutput(false); ASSERT(m_devTools); createDRTDevToolsClient(m_drtDevToolsAgent.get()); } m_devTools->show(WebKit::WebNavigationPolicyNewWindow); }
void ViewListener::OnShowCreatedWebView(WebView *caller, WebView *new_view, const WebURL &opener_url, const WebURL &target_url, const Rect &initial_pos, bool is_popup) { DevMsg("ViewListener: OnShowCreatedWebView: %s\n", WebStringToCharString(target_url.spec())); //C_WebBrowser* pWebBrowser = g_pAnarchyManager->GetWebManager()->GetWebBrowser(); //pWebBrowser->PrepareWebView(new_view); new_view->Destroy(); }
void WebViewHost::loadURLForFrame(const WebURL& url, const WebString& frameName) { if (!url.isValid()) return; TestShell::resizeWindowForTest(this, url); navigationController()->loadEntry(TestNavigationEntry::create(-1, url, WebString(), frameName).get()); }
void WebViewHost::willPerformClientRedirect(WebFrame* frame, const WebURL& from, const WebURL& to, double interval, double fire_time) { if (!m_shell->shouldDumpFrameLoadCallbacks()) return; printFrameDescription(frame); printf(" - willPerformClientRedirectToURL: %s \n", to.spec().data()); }
// REGULAR void LoadListener::OnFinishLoadingFrame(WebView* caller, int64 frame_id, bool is_main_frame, const WebURL& url) { C_AwesomiumBrowserInstance* pHudBrowserInstance = g_pAnarchyManager->GetAwesomiumBrowserManager()->FindAwesomiumBrowserInstance("hud"); std::string urlSpec = WebStringToCharString(url.spec()); if (caller == pHudBrowserInstance->GetWebView() && !g_pAnarchyManager->IsInitialized() && urlSpec == "asset://ui/startup.html" ) { g_pAnarchyManager->OnStartup(); return; } }
void LoadListener::OnDocumentReady(WebView* caller, const WebURL& url) { //DevMsg("LoadListener: OnDocumentReady: %s\n", WebStringToCharString(url.spec())); //C_WebBrowser* pWebBrowser = g_pAnarchyManager->GetWebManager()->GetWebBrowser(); std::string urlSpec = WebStringToCharString(url.spec()); size_t foundPrefix = urlSpec.find("asset://newwindow/"); if (foundPrefix == 0) { // extract a web tab id std::string id = urlSpec.substr(18); DevMsg("Sally: %s\n", urlSpec.c_str()); //if (id == "hud" && g_pAnarchyManager->GetState() == AASTATE_AWESOMIUMBROWSERMANAGERHUDWAIT )// || bHudReady // g_pAnarchyManager->GetAwesomiumBrowserManager()->OnHudWebViewDocumentReady(caller, id); //else g_pAnarchyManager->GetAwesomiumBrowserManager()->OnCreateWebViewDocumentReady(caller, id); } else { //DevMsg("hariy: %s\n", urlSpec.c_str()); //g_pAnarchyManager->GetAwesomiumBrowserManager()->OnHudWebViewDocumentReady(caller, "hud"); // if (!g_pAnarchyManager->GetWebManager()->GetHudReady()) // pWebBrowser->OnHudWebViewDocumentReady(caller, g_pAnarchyManager->GetWebManager()->GetHudWebTab()->GetId()); //{ //foundPrefix = urlSpec.find("asset://ui/loading.html"); //if (foundPrefix == 0) // pWebBrowser->OnHudWebViewDocumentReady(caller, g_pAnarchyManager->GetWebManager()->GetHudWebTab()->GetId()); //foundPrefix = urlSpec.find("asset://ui/hud.html"); //if (foundPrefix == 0) //pWebBrowser->OnHudWebViewDocumentReady(caller, g_pAnarchyManager->GetWebManager()->GetHudWebTab()->GetId()); //else // { // foundPrefix = urlSpec.find("asset://ui/loading.html"); // if (foundPrefix == 0) // pWebBrowser->OnHudWebViewDocumentReady(caller, g_pAnarchyManager->GetWebManager()->GetHudWebTab()->GetId()); //pWebBrowser->OnLoadingWebViewDocumentReady(caller, g_pAnarchyManager->GetWebManager()->GetHudWebTab()->GetId()); // } //} /* else { foundPrefix = urlSpec.find("asset://ui/loading.html"); if ( foundPrefix == 0 ) pWebBrowser->OnLoadingWebViewDocumentReady(caller, g_pAnarchyManager->GetWebManager()->GetHudWebTab()->GetId()); } */ } }
void MasterViewListener::OnShowCreatedWebView(WebView *caller, WebView *new_view, const WebURL &opener_url, const WebURL &target_url, const Rect &initial_pos, bool is_popup) { DevMsg("MasterViewListener: OnShowCreatedWebView: %s\n", WebStringToCharString(target_url.spec())); //C_WebBrowser* pWebBrowser = g_pAnarchyManager->GetWebManager()->GetWebBrowser(); std::string urlSpec = WebStringToCharString(target_url.spec()); size_t foundPrefix = urlSpec.find("asset://newwindow/"); if (foundPrefix == 0) { // extract a web tab id std::string id = urlSpec.substr(18); DevMsg("ID here is: %s\n", id.c_str()); g_pAnarchyManager->GetAwesomiumBrowserManager()->PrepareWebView(new_view, id); } else { new_view->Destroy(); } }
void WebOpenPanelResultListenerProxy::chooseFiles(ImmutableArray* fileURLsArray) { if (!m_page) return; size_t size = fileURLsArray->size(); Vector<String> filePaths; filePaths.reserveInitialCapacity(size); for (size_t i = 0; i < size; ++i) { WebURL* webURL = fileURLsArray->at<WebURL>(i); if (webURL) { KURL url(KURL(), webURL->string()); filePaths.uncheckedAppend(url.fileSystemPath()); } } m_page->didChooseFilesForOpenPanel(filePaths); }
void WebViewHost::willPerformClientRedirect(WebFrame* frame, const WebURL& from, const WebURL& to, double interval, double fire_time) { if (m_shell->shouldDumpFrameLoadCallbacks()) { printFrameDescription(frame); printf(" - willPerformClientRedirectToURL: %s \n", to.spec().data()); } if (m_shell->shouldDumpUserGestureInFrameLoadCallbacks()) printFrameUserGestureStatus(frame, " - in willPerformClientRedirect\n"); }
TEST_F(WebPageSerializerTest, EncodingAndNormalization) { WebURL topFrameURL = toKURL("http://www.test.com"); registerMockedURLLoad(topFrameURL.spec(), WebString::fromUTF8("encoding_normalization.html")); loadURLInTopFrame(topFrameURL); SimpleWebPageSerializerClient serializerClient; WebVector<WebURL> links(&topFrameURL, 1); WebVector<WebString> localPaths(&"local", 1); WebPageSerializer::serialize(webView()->mainFrame()->toWebLocalFrame(), &serializerClient, links, localPaths, ""); const char* expectedHTML = "<!DOCTYPE html>\n" "<!-- saved from url=(0020)http://www.test.com/ -->\n" "<html><head><meta http-equiv=\"Content-Type\" content=\"text/html; charset=EUC-KR\"><meta charset=\"euc-kr\">\n" "<title>Ensure NFC normalization is not performed by page serializer</title>\n" "</head><body>\n" "\xe4\xc5\xd1\xe2\n" "\n</body></html>"; EXPECT_EQ(expectedHTML, serializerClient.toString()); }
TEST_F(WebPageSerializerTest, URLAttributeValues) { WebURL topFrameURL = toKURL("http://www.test.com"); registerMockedURLLoad(topFrameURL.spec(), WebString::fromUTF8("url_attribute_values.html")); registerMockedImageURL("javascript:\""); loadURLInTopFrame(topFrameURL); SimpleWebPageSerializerClient serializerClient; WebVector<WebURL> links(&topFrameURL, 1); WebVector<WebString> localPaths(&"local", 1); WebPageSerializer::serialize(webView()->mainFrame()->toWebLocalFrame(), &serializerClient, links, localPaths, ""); const char* expectedHTML = "\n<!-- saved from url=(0020)http://www.test.com/ -->\n" "<html><head><meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\"><meta charset=\"utf8\">\n" "</head><body><img src=\"javascript:"\">\n" "<a href=\"http://www.test.com/local#"\">local</a>\n" "<a href=\"http://www.example.com/#"><script>alert(0)</script>\">external</a>\n" "</body></html>"; EXPECT_EQ(expectedHTML, serializerClient.toString()); }
void verify(unordered_map<long,WebURL>& webURLs) { unordered_map<long,WebURL>::iterator it; cout<<"\nVERIFYING THE UNORDERED MAP :"<<endl; cout<<"The size of unordered_map = "<<webURLs.size()<<endl; for(it = webURLs.begin(); it != webURLs.end(); it++) { cout<<"Web URL = "<<it->first<<":"<<endl; WebURL myurl = it->second; cout<<"id = "<<myurl.getId()<<"\t"<<"Page Rank = "<<setprecision(15)<<myurl.getNewPageRank()<<"\tOutbound WebURL ids : "; list<WebURL *> listofurls = myurl.getOutboundWebURLs(); list<WebURL *>::iterator listite; for(listite = listofurls.begin(); listite != listofurls.end(); listite++) { WebURL *url = *listite; cout<<url->getId()<<" "; } cout<<endl<<endl; } }
void initializeWebURLs(unordered_map<long,WebURL>& webURLs, long& totalURLs, string inputFile ) { double initialPageRankValue = (double)1/totalURLs; ifstream infile(inputFile,ios::in); string line, url; size_t pos; vector<long> urlArray; if(!infile.is_open()) { string s = "Error : Cannot open the input file \"" + inputFile + "\""; throw s; } while(!infile.eof()) { getline(infile,line); ltrim(line); rtrim(line); urlArray.clear(); if(line.length() > 0) { pos = line.find(' ',0); if(pos > LARGEST_SIZE_T) { // It contains only the master URL and no outbound list of URLs long Webid = atoi(line.c_str()); urlArray.push_back(Webid); } else { while(pos < LARGEST_SIZE_T) { url = line.substr(0,pos); long Webid = atoi(url.c_str()); urlArray.push_back(Webid); line = line.substr(pos + 1); pos = line.find(' ',0); if(pos > LARGEST_SIZE_T && line.length() >0 ) { // This is the last url id on the line url = line; Webid = atoi(url.c_str()); urlArray.push_back(Webid); } } } if(urlArray.size() > 0) { // Insert the URLs in the Hash Table i.e. unordered_map vector<long>::iterator it; long masterURLid; for ( it=urlArray.begin() ; it < urlArray.end(); it++ ) { if(webURLs.find(*it) == webURLs.end()) { WebURL *url = new WebURL((*it),initialPageRankValue); std::pair<long,WebURL> myURL((*it),*url); webURLs.insert(myURL); // copy insertion delete url; } if(it == urlArray.begin()) { masterURLid = *it; // the first Web url id on the line is the master url id } else { WebURL *url = &webURLs.at(masterURLid); url->appendToOutboundList((webURLs.find(*it))->second); } } } } } infile.close(); }
void calculatePageRank(int& iterationNumber, long& totalURLs, unordered_map<long,WebURL>& webURLs,float& dampingFactor) { #ifdef _TRACE cout<<"\nIteration : "<<iterationNumber - 1<<" Dangling Factor = "<<danglingFactor<<endl; #endif double tmpDanglingFactor = 0; unordered_map<long,WebURL>::iterator it; // Iterating through each Key (Representing Page) in the Map and calculating the Page Rank of the pages associated with it. for(it = webURLs.begin(); it != webURLs.end(); it++) { WebURL *masterURL = &(it->second); list<WebURL *> listofOutboundURLs = masterURL->getOutboundWebURLs(); list<WebURL *>::iterator listite; double val; // First time call the evaluate function for the master url to change the iteration number and // calculate the pagerank of the previous iteration masterURL->evaluate(iterationNumber,dampingFactor,totalURLs); #ifdef _TRACE cout<<"src_url: "<<masterURL->getId()<<" cur_val:["<<masterURL->getOldPageRank()<<"]"<<endl; #endif if(!listofOutboundURLs.empty()) { for(listite = listofOutboundURLs.begin(); listite != listofOutboundURLs.end(); listite++) { WebURL *url = *listite; url->evaluate(iterationNumber,dampingFactor,totalURLs); val = (masterURL->getOldPageRank() / (double)(listofOutboundURLs.size())); url->setNewPageRank(val + url->getNewPageRank()); #ifdef _TRACE cout<<" ->tar_url:"<<url->getId()<<" cur_val:"<<url->getOldPageRank()<<" added_val:"<<val<<endl; #endif } } else { tmpDanglingFactor += masterURL->getOldPageRank(); } } // Saving the dangling factor to use it in the next cycle danglingFactor = tmpDanglingFactor; }
static inline bool isSVGTestURL(const WebURL& url) { return url.isValid() && string(url.spec()).find("W3C-SVG-1.1") != string::npos; }
void MasterViewListener::OnChangeTargetURL(WebView* caller, const WebURL &url) { DevMsg("MasterViewListener: OnChangeTargetURL: %s\n", WebStringToCharString(url.spec())); }
void ApplicationCacheHost::notifyErrorEventListener(WebApplicationCacheHost::ErrorReason reason, const WebURL& url, int status, const WebString& message) { notifyApplicationCache(ERROR_EVENT, 0, 0, reason, url.string(), status, message); }
WebString WebPageSerializer::generateMarkOfTheWebDeclaration(const WebURL& url) { return String::format("\n<!-- saved from url=(%04d)%s -->\n", static_cast<int>(url.spec().length()), url.spec().data()); }
void loadURLInTopFrame(const WebURL& url) { FrameTestHelpers::loadFrame(m_helper.webView()->mainFrame(), url.string().utf8().data()); }