* WebKitTestRunner/InjectedBundle/InjectedBundlePage.cpp: Removed unncessary inculde...
[WebKit-https.git] / Tools / WebKitTestRunner / InjectedBundle / InjectedBundlePage.cpp
index da79b19be03a72f84bde64a156adc9aeacf4a5ca..656f97ae786cb3eb9e8e74543499df89fb359977 100644 (file)
@@ -168,7 +168,6 @@ static ostream& operator<<(ostream& out, WKBundleFrameRef frame)
 InjectedBundlePage::InjectedBundlePage(WKBundlePageRef page)
     : m_page(page)
     , m_world(AdoptWK, WKBundleScriptWorldCreateWorld())
-    , m_isLoading(false)
 {
     WKBundlePageLoaderClient loaderClient = {
         0,
@@ -190,7 +189,8 @@ InjectedBundlePage::InjectedBundlePage(WKBundlePageRef page)
         didClearWindowForFrame,
         didCancelClientRedirectForFrame,
         willPerformClientRedirectForFrame,
-        didHandleOnloadEventsForFrame
+        didHandleOnloadEventsForFrame,
+        shouldLoadResourceForFrame
     };
     WKBundlePageSetLoaderClient(m_page, &loaderClient);
 
@@ -232,7 +232,6 @@ InjectedBundlePage::~InjectedBundlePage()
 void InjectedBundlePage::stopLoading()
 {
     WKBundlePageStopLoading(m_page);
-    m_isLoading = false;
 }
 
 void InjectedBundlePage::reset()
@@ -322,14 +321,20 @@ void InjectedBundlePage::didRunInsecureContentForFrame(WKBundlePageRef page, WKB
     static_cast<InjectedBundlePage*>(const_cast<void*>(clientInfo))->didRunInsecureContentForFrame(frame);
 }
 
+bool InjectedBundlePage::shouldLoadResourceForFrame(WKBundlePageRef page, WKBundleFrameRef frame, WKStringRef, const void* clientInfo)
+{
+    return static_cast<InjectedBundlePage*>(const_cast<void*>(clientInfo))->shouldLoadResourceForFrame(frame);
+}
+
 
 void InjectedBundlePage::didStartProvisionalLoadForFrame(WKBundleFrameRef frame)
 {
     if (!InjectedBundle::shared().isTestRunning())
         return;
 
-    if (frame == WKBundlePageGetMainFrame(m_page))
-        m_isLoading = true;
+    if (InjectedBundle::shared().topLoadingFrame())
+        return;
+    InjectedBundle::shared().setTopLoadingFrame(frame);
 }
 
 void InjectedBundlePage::didReceiveServerRedirectForProvisionalLoadForFrame(WKBundleFrameRef frame)
@@ -338,6 +343,17 @@ void InjectedBundlePage::didReceiveServerRedirectForProvisionalLoadForFrame(WKBu
 
 void InjectedBundlePage::didFailProvisionalLoadWithErrorForFrame(WKBundleFrameRef frame, WKErrorRef error)
 {
+    if (!InjectedBundle::shared().isTestRunning())
+        return;
+
+    if (frame != InjectedBundle::shared().topLoadingFrame())
+        return;
+    InjectedBundle::shared().setTopLoadingFrame(0);
+
+    if (InjectedBundle::shared().layoutTestController()->waitToDump())
+        return;
+
+    InjectedBundle::shared().done();
 }
 
 void InjectedBundlePage::didCommitLoadForFrame(WKBundleFrameRef frame)
@@ -469,18 +485,14 @@ void InjectedBundlePage::didFinishLoadForFrame(WKBundleFrameRef frame)
     if (!InjectedBundle::shared().isTestRunning())
         return;
 
-    if (!WKBundleFrameIsMainFrame(frame))
-        return;
-
-    m_isLoading = false;
-
-    if (this != InjectedBundle::shared().page())
+    if (frame != InjectedBundle::shared().topLoadingFrame())
         return;
+    InjectedBundle::shared().setTopLoadingFrame(0);
 
     if (InjectedBundle::shared().layoutTestController()->waitToDump())
         return;
 
-    dump();
+    InjectedBundle::shared().page()->dump();
 }
 
 void InjectedBundlePage::didFailLoadWithErrorForFrame(WKBundleFrameRef frame, WKErrorRef)
@@ -488,12 +500,11 @@ void InjectedBundlePage::didFailLoadWithErrorForFrame(WKBundleFrameRef frame, WK
     if (!InjectedBundle::shared().isTestRunning())
         return;
 
-    if (!WKBundleFrameIsMainFrame(frame))
+    if (frame != InjectedBundle::shared().topLoadingFrame())
         return;
+    InjectedBundle::shared().setTopLoadingFrame(0);
 
-    m_isLoading = false;
-
-    if (this != InjectedBundle::shared().page())
+    if (InjectedBundle::shared().layoutTestController()->waitToDump())
         return;
 
     InjectedBundle::shared().done();
@@ -561,6 +572,11 @@ void InjectedBundlePage::didRunInsecureContentForFrame(WKBundleFrameRef frame)
 {
 }
 
+bool InjectedBundlePage::shouldLoadResourceForFrame(WKBundleFrameRef frame)
+{
+    return true;
+}
+
 // UI Client Callbacks
 
 void InjectedBundlePage::willAddMessageToConsole(WKBundlePageRef page, WKStringRef message, uint32_t lineNumber, const void *clientInfo)