WebKitTools:
authorweinig <weinig@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 12 Sep 2007 19:51:58 +0000 (19:51 +0000)
committerweinig <weinig@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 12 Sep 2007 19:51:58 +0000 (19:51 +0000)
        Rubber stamped by Darin.

        Convert the LayoutTestController to use the JSCore API instead of WebScriptObject.

        * DumpRenderTree/DumpRenderTree.h: Re-order variables.
        * DumpRenderTree/DumpRenderTree.m: Removed.
        * DumpRenderTree/DumpRenderTree.mm: Copied from DumpRenderTree/DumpRenderTree.m.
        (stopJavaScriptThreads): Fix initialization.
        (setDefaultColorProfileToRGB): Add explicit cast from void*.
        (dumpRenderTree): Ditto.
        (runTest):
        Used the WorkQueue from the windows DRT instead of the old NSMutableArray one.

        * DumpRenderTree/DumpRenderTree.xcodeproj/project.pbxproj:
        * DumpRenderTree/FrameLoadDelegate.h: Add LayoutTestController instance variable.
        * DumpRenderTree/FrameLoadDelegate.m: Removed.
        * DumpRenderTree/FrameLoadDelegate.mm: Copied from DumpRenderTree/FrameLoadDelegate.m.
        (-[FrameLoadDelegate init]):
        (-[FrameLoadDelegate dealloc]):
        (-[FrameLoadDelegate processWork:]):
        (-[FrameLoadDelegate webView:locationChangeDone:forDataSource:]):
        (-[FrameLoadDelegate webView:didClearWindowObject:forFrame:]):
        Convert to use the new JSCore based LayoutTestController and the new WorkQueue.

        * DumpRenderTree/LayoutTestController.cpp: Added.
        (LayoutTestController::LayoutTestController):
        (LayoutTestController::~LayoutTestController):
        (dumpAsTextCallback):
        (dumpBackForwardListCallback):
        (dumpChildFramesAsTextCallback):
        (dumpChildFrameScrollPositionsCallback):
        (dumpDOMAsWebArchiveCallback):
        (dumpEditingCallbacksCallback):
        (dumpFrameLoadCallbacksCallback):
        (dumpResourceLoadCallbacksCallback):
        (dumpSelectionRectCallback):
        (dumpSourceAsWebArchiveCallback):
        (dumpTitleChangesCallback):
        (repaintSweepHorizontallyCallback):
        (setCallCloseOnWebViewsCallback):
        (setCanOpenWindowsCallback):
        (setCloseRemainingWindowsWhenCompleteCallback):
        (testRepaintCallback):
        (addFileToPasteboardOnDragCallback):
        (addDisallowedURLCallback):
        (clearBackForwardListCallback):
        (decodeHostNameCallback):
        (displayCallback):
        (encodeHostNameCallback):
        (keepWebHistoryCallback):
        (notifyDoneCallback):
        (queueBackNavigationCallback):
        (queueForwardNavigationCallback):
        (queueLoadCallback):
        (queueReloadCallback):
        (queueScriptCallback):
        (setAcceptsEditingCallback):
        (setCustomPolicyDelegateCallback):
        (setMainFrameIsFirstResponderCallback):
        (setTabKeyCyclesThroughElementsCallback):
        (setUseDashboardCompatibilityModeCallback):
        (setUserStyleSheetEnabledCallback):
        (setUserStyleSheetLocationCallback):
        (setWindowIsKeyCallback):
        (waitUntilDoneCallback):
        (windowCountCallback):
        (LayoutTestController::makeWindowObject):
        (LayoutTestController::getLayoutTestControllerJSClass):
        (LayoutTestController::staticFunctions):
        * DumpRenderTree/LayoutTestController.h: Replaced.
        * DumpRenderTree/LayoutTestController.m: Removed.
        * DumpRenderTree/LayoutTestControllerMac.mm: Added.
        (LayoutTestController::dumpAsText):
        (LayoutTestController::dumpBackForwardList):
        (LayoutTestController::dumpChildFramesAsText):
        (LayoutTestController::dumpChildFrameScrollPositions):
        (LayoutTestController::dumpDOMAsWebArchive):
        (LayoutTestController::dumpEditingCallbacks):
        (LayoutTestController::dumpFrameLoadCallbacks):
        (LayoutTestController::dumpResourceLoadCallbacks):
        (LayoutTestController::dumpSelectionRect):
        (LayoutTestController::dumpSourceAsWebArchive):
        (LayoutTestController::dumpTitleChanges):
        (LayoutTestController::repaintSweepHorizontally):
        (LayoutTestController::setCallCloseOnWebViews):
        (LayoutTestController::setCanOpenWindows):
        (LayoutTestController::setCloseRemainingWindowsWhenComplete):
        (LayoutTestController::testRepaint):
        (LayoutTestController::addFileToPasteboardOnDrag):
        (LayoutTestController::addDisallowedURL):
        (LayoutTestController::clearBackForwardList):
        (LayoutTestController::decodeHostName):
        (LayoutTestController::encodeHostName):
        (LayoutTestController::display):
        (LayoutTestController::keepWebHistory):
        (LayoutTestController::notifyDone):
        (LayoutTestController::queueBackNavigation):
        (LayoutTestController::queueForwardNavigation):
        (LayoutTestController::queueLoad):
        (LayoutTestController::queueReload):
        (LayoutTestController::queueScript):
        (LayoutTestController::setAcceptsEditing):
        (LayoutTestController::setCustomPolicyDelegate):
        (LayoutTestController::setMainFrameIsFirstResponder):
        (LayoutTestController::setTabKeyCyclesThroughElements):
        (LayoutTestController::setUseDashboardCompatibilityMode):
        (LayoutTestController::setUserStyleSheetEnabled):
        (LayoutTestController::setUserStyleSheetLocation):
        (LayoutTestController::setWindowIsKey):
        (+[WaitToDumpWatchdog waitUntilDoneWatchdogFired]):
        (LayoutTestController::waitUntilDone):
        (LayoutTestController::windowCount):
        Use the JSCore API to implement the LayoutTestController.

        * DumpRenderTree/ObjCController.h:
        * DumpRenderTree/ObjCController.m:
        (+[ObjCController isSelectorExcludedFromWebScript:]):
        (+[ObjCController webScriptNameForSelector:]):
        (-[ObjCController accessStoredWebScriptObject]):
        (-[ObjCController storeWebScriptObject:]):
        (-[ObjCController dealloc]):
        (-[ObjCController invokeUndefinedMethodFromWebScript:withArguments:]):
        Move WebScriptObject tests to ObjCController.

        * DumpRenderTree/UIDelegate.m: Removed.
        * DumpRenderTree/UIDelegate.mm: Copied from DumpRenderTree/UIDelegate.m.

        * DumpRenderTree/WorkQueue.cpp: Copied from DumpRenderTree/DumpRenderTree.vcproj/DumpRenderTree/WorkQueue.cpp.
        * DumpRenderTree/WorkQueue.h: Copied from DumpRenderTree/DumpRenderTree.vcproj/DumpRenderTree/WorkQueue.h.
        * DumpRenderTree/WorkQueueItem.h: Copied from DumpRenderTree/DumpRenderTree.vcproj/DumpRenderTree/WorkQueueItem.h.
        (WorkQueueItem::~WorkQueueItem):
        (LoadItem::LoadItem):
        (LoadItem::url):
        (LoadItem::target):
        (ScriptItem::ScriptItem):
        (ScriptItem::script):
        * DumpRenderTree/WorkQueueItemMac.mm: Added.
        (LoadItem::invoke):
        (ReloadItem::invoke):
        (ScriptItem::invoke):
        (BackForwardItem::invoke):
        Copy WorkQueue and WorkQueueItem from windows DRT. Changed the WorkQueueItem to use JSStringRefs instead of wstrings
        to avoid conversion until the last possible moment.  These changes will be merged with the windows DRT when we start
        sharing code.

LayoutTests:

        Rubber stamped by Darin.

        Fix layout tests for new JSCore API based LayoutTestController.

        * fast/dom/resources/wrapper-identity-base.js: Use ObjCController for objective-c tests.
        * http/tests/local/file-url-sent-as-referer.html: Remove unused illegal call that now causes controller to fail due to not allowing undefined method calls.
        * http/tests/xmlhttprequest/default-content-type-dashboard.html: Fix typo in function name.
        * http/tests/xmlhttprequest/svg-created-by-xhr-disallowed-in-dashboard.html: Fix typo in function name.
        * plugins/call-as-function-test-expected.txt:
        * plugins/call-as-function-test.html: Use ObjCController to test WebScriptObject.
        * plugins/root-object-premature-delete-crash.html: Use ObjCController to test WebScriptObject
        * plugins/undefined-property-crash.html: Use ObjCController to test WebScriptObject.
        * svg/custom/embedded-svg-disallowed-in-dashboard.xml: Fix typo in function name.
        * svg/custom/manually-parsed-embedded-svg-disallowed-in-dashboard.html: Fix typo in function name.
        * svg/custom/manually-parsed-svg-disallowed-in-dashboard.html: Fix typo in function name.
        * svg/custom/svg-disallowed-in-dashboard-object.html: Fix typo in function name.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@25515 268f45cc-cd09-0410-ab3c-d52691b4dbfc

30 files changed:
LayoutTests/ChangeLog
LayoutTests/fast/dom/resources/wrapper-identity-base.js
LayoutTests/http/tests/local/file-url-sent-as-referer.html
LayoutTests/http/tests/xmlhttprequest/default-content-type-dashboard.html
LayoutTests/http/tests/xmlhttprequest/svg-created-by-xhr-disallowed-in-dashboard.html
LayoutTests/plugins/call-as-function-test-expected.txt
LayoutTests/plugins/call-as-function-test.html
LayoutTests/plugins/root-object-premature-delete-crash.html
LayoutTests/plugins/undefined-property-crash.html
LayoutTests/svg/custom/embedded-svg-disallowed-in-dashboard.xml
LayoutTests/svg/custom/manually-parsed-embedded-svg-disallowed-in-dashboard.html
LayoutTests/svg/custom/manually-parsed-svg-disallowed-in-dashboard.html
LayoutTests/svg/custom/svg-disallowed-in-dashboard-object.html
WebKitTools/ChangeLog
WebKitTools/DumpRenderTree/DumpRenderTree.h
WebKitTools/DumpRenderTree/DumpRenderTree.mm [moved from WebKitTools/DumpRenderTree/DumpRenderTree.m with 98% similarity]
WebKitTools/DumpRenderTree/DumpRenderTree.xcodeproj/project.pbxproj
WebKitTools/DumpRenderTree/FrameLoadDelegate.h
WebKitTools/DumpRenderTree/FrameLoadDelegate.mm [moved from WebKitTools/DumpRenderTree/FrameLoadDelegate.m with 93% similarity]
WebKitTools/DumpRenderTree/LayoutTestController.cpp [new file with mode: 0644]
WebKitTools/DumpRenderTree/LayoutTestController.h
WebKitTools/DumpRenderTree/LayoutTestController.m [deleted file]
WebKitTools/DumpRenderTree/LayoutTestControllerMac.mm [new file with mode: 0644]
WebKitTools/DumpRenderTree/ObjCController.h
WebKitTools/DumpRenderTree/ObjCController.m
WebKitTools/DumpRenderTree/UIDelegate.mm [moved from WebKitTools/DumpRenderTree/UIDelegate.m with 100% similarity]
WebKitTools/DumpRenderTree/WorkQueue.cpp [new file with mode: 0644]
WebKitTools/DumpRenderTree/WorkQueue.h [new file with mode: 0644]
WebKitTools/DumpRenderTree/WorkQueueItem.h [new file with mode: 0644]
WebKitTools/DumpRenderTree/WorkQueueItemMac.mm [new file with mode: 0644]

index 91be357..3d12c35 100644 (file)
@@ -1,3 +1,22 @@
+2007-09-12  Sam Weinig  <sam@webkit.org>
+
+        Rubber stamped by Darin.
+
+        Fix layout tests for new JSCore API based LayoutTestController.
+
+        * fast/dom/resources/wrapper-identity-base.js: Use ObjCController for objective-c tests.
+        * http/tests/local/file-url-sent-as-referer.html: Remove unused illegal call that now causes controller to fail due to not allowing undefined method calls.
+        * http/tests/xmlhttprequest/default-content-type-dashboard.html: Fix typo in function name.
+        * http/tests/xmlhttprequest/svg-created-by-xhr-disallowed-in-dashboard.html: Fix typo in function name.
+        * plugins/call-as-function-test-expected.txt:
+        * plugins/call-as-function-test.html: Use ObjCController to test WebScriptObject.
+        * plugins/root-object-premature-delete-crash.html: Use ObjCController to test WebScriptObject
+        * plugins/undefined-property-crash.html: Use ObjCController to test WebScriptObject.
+        * svg/custom/embedded-svg-disallowed-in-dashboard.xml: Fix typo in function name.
+        * svg/custom/manually-parsed-embedded-svg-disallowed-in-dashboard.html: Fix typo in function name.
+        * svg/custom/manually-parsed-svg-disallowed-in-dashboard.html: Fix typo in function name.
+        * svg/custom/svg-disallowed-in-dashboard-object.html: Fix typo in function name.
+
 2007-09-12  Oliver Hunt  <oliver@apple.com>
 
         Rubber stamped by Kevin D.
index 42b190e..093e75e 100644 (file)
@@ -170,7 +170,7 @@ function isEqualJS(a, b)
 
 function isEqualObjC(a, b)
 {
-    return Boolean(layoutTestController.objCIdentityIsEqual(a, b));
+    return Boolean(objCController.identityIsEqual(a, b));
 }
 
 function testJS(s)
index 248b0ca..ed8420b 100644 (file)
@@ -1,9 +1,6 @@
 <html>
 <head>
-    <script>  
-        if (window.layoutTestController)
-            layoutTestController.dump();
-        
+    <script>
         function getImage()
         {
             var frameObj = document.getElementById("myFrame");
index 22aee46..bc5cccf 100644 (file)
@@ -3,7 +3,7 @@
 <p>This tests that the default Content-Type for XMLHttpRequest is application/x-www-form-urlencoded when running in the Dashboard compatibility mode.</p>
 <script>
     if (window.layoutTestController) {
-        layoutTestController.setUseDashboardCompatiblityMode(true);
+        layoutTestController.setUseDashboardCompatibilityMode(true);
         layoutTestController.dumpAsText();
     }
     
index 08870ad..59f6557 100644 (file)
@@ -71,7 +71,7 @@
 <pre id="console"></pre>
 <script>
     if (window.layoutTestController) {
-        layoutTestController.setUseDashboardCompatiblityMode(true);
+        layoutTestController.setUseDashboardCompatibilityMode(true);
         layoutTestController.dumpAsText();
         layoutTestController.waitUntilDone();
     }
index 8aa61ba..1767053 100644 (file)
@@ -1,2 +1,2 @@
-TypeError: function dumpAsText() { [native code] }
-TypeError: function dumpAsText() { [native code] }
+TypeError: function className() { [native code] }
+TypeError: function className() { [native code] }
index 0f7f40c..a523b12 100644 (file)
@@ -7,7 +7,7 @@
                 layoutTestController.dumpAsText();
 
             // Test calling bridged function with global window as "this"
-            var f = ("layoutTestController" in window) ? layoutTestController.dumpAsText : console.log;
+            var f = ("layoutTestController" in window) ? objCController.className : console.log;
             
             var result;
             try {
index f47f151..9a1f7c8 100644 (file)
@@ -21,7 +21,7 @@ var count = 0;
 function runTest()
 {
     // Use a possibly stale pointer.
-    layoutTestController.accessStoredWebScriptObject(); 
+    objCController.accessStoredWebScriptObject(); 
 
     // Repeat, just to be sure.
     if (++count < 100) { // >
@@ -36,14 +36,14 @@ function runTest()
 function queueTest()
 {
     iframe.onload = runTest;
-    layoutTestController.storeWebScriptObject(iframe.contentWindow);
+    objCController.storeWebScriptObject(iframe.contentWindow);
     iframe.contentWindow.location.reload();
 }
 
 window.onload = function onload()
 {
-    if (!("layoutTestController" in window)) {
-        var errorMessage = "FAIL: This test can only run inside DumpRenderTree.";
+    if (!("layoutTestController" in window) || !("objCController" in window)) {
+        var errorMessage = "FAIL: This test can only run inside DumpRenderTree on the mac.";
         log(errorMessage);
         throw errorMessage;
     }
index 09c1654..30cc13a 100644 (file)
@@ -9,18 +9,21 @@ function print(message) {
 
 function test2()
 {
-    return layoutTestController.doesNotExist;
+    return objCController.doesNotExist;
 }
 
 function test()
 {
+    if (!window.objCController) {
+        print("FAIL: window.objCController does not exist");
+        return;
+    }
+
     if (window.layoutTestController)
         layoutTestController.dumpAsText();
-    else
-        print("FAIL: window.layoutTestController does not exist");
-        
+
     var crasher = test2();
-    delete layoutTestController;
+    delete objCController;
     
     // create lots of objects to force a garbage collection
     var i = 0;
@@ -33,13 +36,12 @@ function test()
     if (crasher) {} // force call to toBoolean
     if (crasher == null) {} // force call to type() through call to equal
     
-    if (window.layoutTestController)   
-        print("FAIL: unable to delete layoutTestController");
+    if (window.objCController)
+        print("FAIL: unable to delete objCController");
     else
         print("PASS: You didn't crash.");
 }
 </script>
-       
 </head>
 <body onload="test()">
 <p>
index 3a68b9d..587591d 100644 (file)
@@ -4,7 +4,7 @@
     </head>
     <script>
          if (window.layoutTestController) {
-             layoutTestController.setUseDashboardCompatiblityMode(true);
+             layoutTestController.setUseDashboardCompatibilityMode(true);
              layoutTestController.dumpAsText();
          }
          function debug(str) {
index 2e06121..e29743d 100644 (file)
@@ -9,7 +9,7 @@
         }
         
         if (window.layoutTestController) {
-            layoutTestController.setUseDashboardCompatiblityMode(true);
+            layoutTestController.setUseDashboardCompatibilityMode(true);
             layoutTestController.dumpAsText();
         }
     </script>
index 5aea37d..e980971 100644 (file)
@@ -9,7 +9,7 @@
         }
         
         if (window.layoutTestController) {
-            layoutTestController.setUseDashboardCompatiblityMode(true);
+            layoutTestController.setUseDashboardCompatibilityMode(true);
             layoutTestController.dumpAsText();
         }
     </script>
index 1f8acd0..c808033 100644 (file)
@@ -3,7 +3,7 @@
 <p>This test makes sure we can't open SVG documents in Dashboard compatibility mode.  It can not be tested manually.</p>
 <script>
     if (window.layoutTestController) {
-        layoutTestController.setUseDashboardCompatiblityMode(true);
+        layoutTestController.setUseDashboardCompatibilityMode(true);
         layoutTestController.dumpAsText();
         layoutTestController.waitUntilDone();
     }
index 51c571d..2819484 100644 (file)
@@ -1,3 +1,150 @@
+2007-09-12  Sam Weinig  <sam@webkit.org>
+
+        Rubber stamped by Darin.
+
+        Convert the LayoutTestController to use the JSCore API instead of WebScriptObject.
+
+        * DumpRenderTree/DumpRenderTree.h: Re-order variables. 
+        * DumpRenderTree/DumpRenderTree.m: Removed.
+        * DumpRenderTree/DumpRenderTree.mm: Copied from DumpRenderTree/DumpRenderTree.m.
+        (stopJavaScriptThreads): Fix initialization.
+        (setDefaultColorProfileToRGB): Add explicit cast from void*.
+        (dumpRenderTree): Ditto.
+        (runTest):
+        Used the WorkQueue from the windows DRT instead of the old NSMutableArray one.
+
+        * DumpRenderTree/DumpRenderTree.xcodeproj/project.pbxproj:
+        * DumpRenderTree/FrameLoadDelegate.h: Add LayoutTestController instance variable.
+        * DumpRenderTree/FrameLoadDelegate.m: Removed.
+        * DumpRenderTree/FrameLoadDelegate.mm: Copied from DumpRenderTree/FrameLoadDelegate.m.
+        (-[FrameLoadDelegate init]):
+        (-[FrameLoadDelegate dealloc]):
+        (-[FrameLoadDelegate processWork:]):
+        (-[FrameLoadDelegate webView:locationChangeDone:forDataSource:]):
+        (-[FrameLoadDelegate webView:didClearWindowObject:forFrame:]):
+        Convert to use the new JSCore based LayoutTestController and the new WorkQueue.
+        
+        * DumpRenderTree/LayoutTestController.cpp: Added.
+        (LayoutTestController::LayoutTestController):
+        (LayoutTestController::~LayoutTestController):
+        (dumpAsTextCallback):
+        (dumpBackForwardListCallback):
+        (dumpChildFramesAsTextCallback):
+        (dumpChildFrameScrollPositionsCallback):
+        (dumpDOMAsWebArchiveCallback):
+        (dumpEditingCallbacksCallback):
+        (dumpFrameLoadCallbacksCallback):
+        (dumpResourceLoadCallbacksCallback):
+        (dumpSelectionRectCallback):
+        (dumpSourceAsWebArchiveCallback):
+        (dumpTitleChangesCallback):
+        (repaintSweepHorizontallyCallback):
+        (setCallCloseOnWebViewsCallback):
+        (setCanOpenWindowsCallback):
+        (setCloseRemainingWindowsWhenCompleteCallback):
+        (testRepaintCallback):
+        (addFileToPasteboardOnDragCallback):
+        (addDisallowedURLCallback):
+        (clearBackForwardListCallback):
+        (decodeHostNameCallback):
+        (displayCallback):
+        (encodeHostNameCallback):
+        (keepWebHistoryCallback):
+        (notifyDoneCallback):
+        (queueBackNavigationCallback):
+        (queueForwardNavigationCallback):
+        (queueLoadCallback):
+        (queueReloadCallback):
+        (queueScriptCallback):
+        (setAcceptsEditingCallback):
+        (setCustomPolicyDelegateCallback):
+        (setMainFrameIsFirstResponderCallback):
+        (setTabKeyCyclesThroughElementsCallback):
+        (setUseDashboardCompatibilityModeCallback):
+        (setUserStyleSheetEnabledCallback):
+        (setUserStyleSheetLocationCallback):
+        (setWindowIsKeyCallback):
+        (waitUntilDoneCallback):
+        (windowCountCallback):
+        (LayoutTestController::makeWindowObject):
+        (LayoutTestController::getLayoutTestControllerJSClass):
+        (LayoutTestController::staticFunctions):
+        * DumpRenderTree/LayoutTestController.h: Replaced.
+        * DumpRenderTree/LayoutTestController.m: Removed.
+        * DumpRenderTree/LayoutTestControllerMac.mm: Added.
+        (LayoutTestController::dumpAsText):
+        (LayoutTestController::dumpBackForwardList):
+        (LayoutTestController::dumpChildFramesAsText):
+        (LayoutTestController::dumpChildFrameScrollPositions):
+        (LayoutTestController::dumpDOMAsWebArchive):
+        (LayoutTestController::dumpEditingCallbacks):
+        (LayoutTestController::dumpFrameLoadCallbacks):
+        (LayoutTestController::dumpResourceLoadCallbacks):
+        (LayoutTestController::dumpSelectionRect):
+        (LayoutTestController::dumpSourceAsWebArchive):
+        (LayoutTestController::dumpTitleChanges):
+        (LayoutTestController::repaintSweepHorizontally):
+        (LayoutTestController::setCallCloseOnWebViews):
+        (LayoutTestController::setCanOpenWindows):
+        (LayoutTestController::setCloseRemainingWindowsWhenComplete):
+        (LayoutTestController::testRepaint):
+        (LayoutTestController::addFileToPasteboardOnDrag):
+        (LayoutTestController::addDisallowedURL):
+        (LayoutTestController::clearBackForwardList):
+        (LayoutTestController::decodeHostName):
+        (LayoutTestController::encodeHostName):
+        (LayoutTestController::display):
+        (LayoutTestController::keepWebHistory):
+        (LayoutTestController::notifyDone):
+        (LayoutTestController::queueBackNavigation):
+        (LayoutTestController::queueForwardNavigation):
+        (LayoutTestController::queueLoad):
+        (LayoutTestController::queueReload):
+        (LayoutTestController::queueScript):
+        (LayoutTestController::setAcceptsEditing):
+        (LayoutTestController::setCustomPolicyDelegate):
+        (LayoutTestController::setMainFrameIsFirstResponder):
+        (LayoutTestController::setTabKeyCyclesThroughElements):
+        (LayoutTestController::setUseDashboardCompatibilityMode):
+        (LayoutTestController::setUserStyleSheetEnabled):
+        (LayoutTestController::setUserStyleSheetLocation):
+        (LayoutTestController::setWindowIsKey):
+        (+[WaitToDumpWatchdog waitUntilDoneWatchdogFired]):
+        (LayoutTestController::waitUntilDone):
+        (LayoutTestController::windowCount):
+        Use the JSCore API to implement the LayoutTestController.
+
+        * DumpRenderTree/ObjCController.h:
+        * DumpRenderTree/ObjCController.m:
+        (+[ObjCController isSelectorExcludedFromWebScript:]):
+        (+[ObjCController webScriptNameForSelector:]):
+        (-[ObjCController accessStoredWebScriptObject]):
+        (-[ObjCController storeWebScriptObject:]):
+        (-[ObjCController dealloc]):
+        (-[ObjCController invokeUndefinedMethodFromWebScript:withArguments:]):
+        Move WebScriptObject tests to ObjCController.
+
+        * DumpRenderTree/UIDelegate.m: Removed.
+        * DumpRenderTree/UIDelegate.mm: Copied from DumpRenderTree/UIDelegate.m.
+
+        * DumpRenderTree/WorkQueue.cpp: Copied from DumpRenderTree/DumpRenderTree.vcproj/DumpRenderTree/WorkQueue.cpp.
+        * DumpRenderTree/WorkQueue.h: Copied from DumpRenderTree/DumpRenderTree.vcproj/DumpRenderTree/WorkQueue.h.
+        * DumpRenderTree/WorkQueueItem.h: Copied from DumpRenderTree/DumpRenderTree.vcproj/DumpRenderTree/WorkQueueItem.h.
+        (WorkQueueItem::~WorkQueueItem):
+        (LoadItem::LoadItem):
+        (LoadItem::url):
+        (LoadItem::target):
+        (ScriptItem::ScriptItem):
+        (ScriptItem::script):
+        * DumpRenderTree/WorkQueueItemMac.mm: Added.
+        (LoadItem::invoke):
+        (ReloadItem::invoke):
+        (ScriptItem::invoke):
+        (BackForwardItem::invoke):
+        Copy WorkQueue and WorkQueueItem from windows DRT. Changed the WorkQueueItem to use JSStringRefs instead of wstrings
+        to avoid conversion until the last possible moment.  These changes will be merged with the windows DRT when we start
+        sharing code.
+
 2007-09-11  Kevin McCullough  <kmccullough@apple.com>
 
         Reviewed by Maciej.
index 98a577c..dd11ae5 100644 (file)
@@ -26,6 +26,7 @@
  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
+
 @class DumpRenderTreeDraggingInfo;
 @class EditingDelegate;
 @class FrameLoadDelegate;
@@ -52,24 +53,24 @@ extern BOOL windowIsKey;
 extern BOOL shouldDumpEditingCallbacks;
 extern BOOL shouldDumpResourceLoadCallbacks;
 extern BOOL shouldDumpFrameLoadCallbacks;
-extern WebFrame *mainFrame;
-extern DumpRenderTreeDraggingInfo *draggingInfo;
-extern volatile BOOL done;
 extern BOOL shouldDumpResourceLoadCallbacks;
 extern BOOL shouldDumpFrameLoadCallbacks;
-extern NSMutableSet *disallowedURLs;
 extern BOOL waitToDump;
 extern BOOL canOpenWindows;
 extern BOOL closeWebViews;
 extern BOOL closeRemainingWindowsWhenComplete;
 extern BOOL addFileToPasteboardOnDrag;
-extern NSMutableArray *workQueue;
+
+extern volatile BOOL done;
+
+extern WebFrame *mainFrame;
+extern DumpRenderTreeDraggingInfo *draggingInfo;
 extern WebFrame *topLoadingFrame;
-extern BOOL workQueueFrozen;
 extern NavigationController *navigationController;
 extern NSTimer *waitToDumpWatchdog;
 extern NSTimeInterval waitToDumpWatchdogInterval;
 extern CFMutableArrayRef allWindowsRef;
+extern NSMutableSet *disallowedURLs;
 
 // Delegates
 extern FrameLoadDelegate *frameLoadDelegate;
@@ -81,4 +82,3 @@ extern PolicyDelegate *policyDelegate;
 WebView *createWebView();
 void displayWebView();
 void dump(void);
-
similarity index 98%
rename from WebKitTools/DumpRenderTree/DumpRenderTree.m
rename to WebKitTools/DumpRenderTree/DumpRenderTree.mm
index f91b763..a3eea6f 100644 (file)
@@ -38,6 +38,8 @@
 #import "PolicyDelegate.h"
 #import "ResourceLoadDelegate.h"
 #import "UIDelegate.h"
+#import "WorkQueueItem.h"
+#import "WorkQueue.h"
 
 #import <ApplicationServices/ApplicationServices.h> // for CMSetDefaultProfileBySpace
 #import <CoreFoundation/CoreFoundation.h>
@@ -87,6 +89,8 @@
 }
 @end
 
+LayoutTestController* layoutTestController = 0;
+
 BOOL windowIsKey = YES;
 WebFrame *mainFrame = 0;
 BOOL shouldDumpEditingCallbacks;
@@ -155,12 +159,6 @@ static WebHistoryItem *prevTestBFItem = nil;  // current b/f item at the end of
 static unsigned char* screenCaptureBuffer;
 static CGColorSpaceRef sharedColorSpace;
 
-// a queue of NSInvocations, queued by callouts from the test, to be exec'ed when the load is done
-NSMutableArray *workQueue = nil;
-// to prevent infinite loops, only the first page of a test can add to a work queue
-// (since we may well come back to that same page)
-BOOL workQueueFrozen = NO;
-
 const unsigned maxViewHeight = 600;
 const unsigned maxViewWidth = 800;
 
@@ -245,17 +243,18 @@ static void stopJavaScriptThreads(void)
 {
     pthread_mutex_lock(&javaScriptThreadsMutex);
 
-    javaScriptThreadsShouldTerminate = YES;
+    javaScriptThreadsShouldTerminate = true;
 
-    const pthread_t pthreads[javaScriptThreadsCount];
-    assert(CFDictionaryGetCount(javaScriptThreads()) == javaScriptThreadsCount);
-    CFDictionaryGetKeysAndValues(javaScriptThreads(), (const void**)pthreads, NULL);
+    pthread_t* pthreads[javaScriptThreadsCount] = { 0 };
+    ASSERT(CFDictionaryGetCount(javaScriptThreads()) == javaScriptThreadsCount);
+    CFDictionaryGetKeysAndValues(javaScriptThreads(), (const void**)pthreads, 0);
 
     pthread_mutex_unlock(&javaScriptThreadsMutex);
 
     for (int i = 0; i < javaScriptThreadsCount; i++) {
-        pthread_t pthread = pthreads[i];
-        pthread_join(pthread, NULL);
+        pthread_t* pthread = pthreads[i];
+        pthread_join(*pthread, 0);
+        free(pthread);
     }
 }
 
@@ -314,7 +313,7 @@ static void activateAhemFont(void)
 
 static void setDefaultColorProfileToRGB(void)
 {
-    CMProfileRef genericProfile = [[NSColorSpace genericRGBColorSpace] colorSyncProfile];
+    CMProfileRef genericProfile = (CMProfileRef)[[NSColorSpace genericRGBColorSpace] colorSyncProfile];
     CMProfileRef previousProfile;
     int error = CMGetDefaultProfileByUse(cmDisplayUse, &previousProfile);
     if (error) {
@@ -512,7 +511,7 @@ void dumpRenderTree(int argc, const char *argv[])
 
     if (dumpPixels) {
         setDefaultColorProfileToRGB();
-        screenCaptureBuffer = malloc(maxViewHeight * maxViewWidth * 4);
+        screenCaptureBuffer = (unsigned char *)malloc(maxViewHeight * maxViewWidth * 4);
         sharedColorSpace = CGColorSpaceCreateDeviceRGB();
     }
     
@@ -531,8 +530,6 @@ void dumpRenderTree(int argc, const char *argv[])
     WebView *webView = createWebView();    
     mainFrame = [webView mainFrame];
     NSWindow *window = [webView window];
-    
-    workQueue = [[NSMutableArray alloc] init];
 
     makeLargeMallocFailSilently();
 
@@ -576,8 +573,6 @@ void dumpRenderTree(int argc, const char *argv[])
 
     if (threaded)
         stopJavaScriptThreads();
-    
-    [workQueue release];
 
     [WebCoreStatistics emptyCache]; // Otherwise SVGImages trigger false positives for Frame/Node counts    
     [webView close];
@@ -1030,6 +1025,8 @@ static void runTest(const char *pathOrURL)
         return;
     }
 
+    
+
     [(EditingDelegate *)[[mainFrame webView] editingDelegate] setAcceptsEditing:YES];
     [[mainFrame webView] makeTextStandardSize:nil];
     [[mainFrame webView] setTabKeyCyclesThroughElements: YES];
@@ -1066,8 +1063,9 @@ static void runTest(const char *pathOrURL)
     currentTest = (NSString *)pathOrURLString;
     [prevTestBFItem release];
     prevTestBFItem = [[[[mainFrame webView] backForwardList] currentItem] retain];
-    [workQueue removeAllObjects];
-    workQueueFrozen = NO;
+
+    WorkQueue::shared()->clear();
+    WorkQueue::shared()->setFrozen(false);
 
     BOOL _shouldIgnoreWebCoreNodeLeaks = shouldIgnoreWebCoreNodeLeaks(CFURLGetString(URL));
     if (_shouldIgnoreWebCoreNodeLeaks)
index 8811f5e..5c1534e 100644 (file)
@@ -33,7 +33,6 @@
                141BF44C096A45C800E0753C /* Info.plist in Resources */ = {isa = PBXBuildFile; fileRef = 141BF448096A45C800E0753C /* Info.plist */; };
                141BF453096A45EB00E0753C /* PluginObject.h in Headers */ = {isa = PBXBuildFile; fileRef = 141BF447096A45C800E0753C /* PluginObject.h */; };
                1422A1BA0AF6EDD600E1A883 /* UIDelegate.h in Headers */ = {isa = PBXBuildFile; fileRef = 1422A1B80AF6EDD600E1A883 /* UIDelegate.h */; };
-               1422A1BB0AF6EDD600E1A883 /* UIDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 1422A1B90AF6EDD600E1A883 /* UIDelegate.m */; };
                14770FE20A22ADF7009342EE /* GCController.h in Headers */ = {isa = PBXBuildFile; fileRef = 14770FE00A22ADF7009342EE /* GCController.h */; };
                14770FE30A22ADF7009342EE /* GCController.mm in Sources */ = {isa = PBXBuildFile; fileRef = 14770FE10A22ADF7009342EE /* GCController.mm */; };
                14A6FB8A0971CAE5008B014F /* NavigationController.h in Headers */ = {isa = PBXBuildFile; fileRef = 14A6FB880971CAE5008B014F /* NavigationController.h */; };
                22181BD209DC8C4B008342E8 /* ObjCPlugin.m in Sources */ = {isa = PBXBuildFile; fileRef = 22181BCE09DC8C4B008342E8 /* ObjCPlugin.m */; };
                22181BD309DC8C4B008342E8 /* ObjCPluginFunction.h in Headers */ = {isa = PBXBuildFile; fileRef = 22181BCF09DC8C4B008342E8 /* ObjCPluginFunction.h */; };
                22181BD409DC8C4B008342E8 /* ObjCPluginFunction.m in Sources */ = {isa = PBXBuildFile; fileRef = 22181BD009DC8C4B008342E8 /* ObjCPluginFunction.m */; };
-               6508A2980BFABB8000AD2696 /* FrameLoadDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 6508A26D0BFAB71B00AD2696 /* FrameLoadDelegate.m */; };
                6508A2990BFABB8100AD2696 /* FrameLoadDelegate.h in Headers */ = {isa = PBXBuildFile; fileRef = 6508A26C0BFAB71B00AD2696 /* FrameLoadDelegate.h */; };
                6508A29A0BFABB8200AD2696 /* ResourceLoadDelegate.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A6CA8630B7120CF00A24B62 /* ResourceLoadDelegate.h */; };
                9340994C08540CAE007F3BC8 /* DumpRenderTreePrefix.h in Headers */ = {isa = PBXBuildFile; fileRef = 32A70AAB03705E1F00C91783 /* DumpRenderTreePrefix.h */; };
-               9340994E08540CAE007F3BC8 /* DumpRenderTree.m in Sources */ = {isa = PBXBuildFile; fileRef = 08FB7796FE84155DC02AAC07 /* DumpRenderTree.m */; settings = {ATTRIBUTES = (); COMPILER_FLAGS = "-Wno-deprecated-declarations"; }; };
                9340995108540CAE007F3BC8 /* WebKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 9335435F03D75502008635CE /* WebKit.framework */; };
                93442CF608F8BA4900BFE8CA /* TextInputController.h in Headers */ = {isa = PBXBuildFile; fileRef = 93442CF408F8BA4900BFE8CA /* TextInputController.h */; };
                93442CF708F8BA4900BFE8CA /* TextInputController.m in Sources */ = {isa = PBXBuildFile; fileRef = 93442CF508F8BA4900BFE8CA /* TextInputController.m */; };
                AE8259F408D22463000507AB /* Carbon.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = AE8257EF08D22389000507AB /* Carbon.framework */; };
                B5A752A008AF5CD400138E45 /* ImageDiff.m in Sources */ = {isa = PBXBuildFile; fileRef = B5A7525808AF4A3600138E45 /* ImageDiff.m */; };
                B5A752A208AF5D1F00138E45 /* QuartzCore.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = B5A752A108AF5D1F00138E45 /* QuartzCore.framework */; };
+               BC0131DA0C9772010087317D /* LayoutTestController.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BC0131D80C9772010087317D /* LayoutTestController.cpp */; };
+               BC0131DB0C9772010087317D /* LayoutTestController.h in Headers */ = {isa = PBXBuildFile; fileRef = BC0131D90C9772010087317D /* LayoutTestController.h */; };
+               BC0131EF0C9774700087317D /* WorkQueueItemMac.mm in Sources */ = {isa = PBXBuildFile; fileRef = BC0131EE0C9774700087317D /* WorkQueueItemMac.mm */; };
+               BC9D90240C97472E0099A4A3 /* WorkQueue.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BC9D90210C97472D0099A4A3 /* WorkQueue.cpp */; };
+               BC9D90250C97472E0099A4A3 /* WorkQueue.h in Headers */ = {isa = PBXBuildFile; fileRef = BC9D90220C97472E0099A4A3 /* WorkQueue.h */; };
+               BC9D90260C97472E0099A4A3 /* WorkQueueItem.h in Headers */ = {isa = PBXBuildFile; fileRef = BC9D90230C97472E0099A4A3 /* WorkQueueItem.h */; };
+               BCA51CFD0C95DFB30076A81A /* FrameLoadDelegate.mm in Sources */ = {isa = PBXBuildFile; fileRef = BCA51CFC0C95DFB30076A81A /* FrameLoadDelegate.mm */; };
+               BCA51D090C95DFE80076A81A /* DumpRenderTree.mm in Sources */ = {isa = PBXBuildFile; fileRef = BCA51D080C95DFE80076A81A /* DumpRenderTree.mm */; };
+               BCA51DE60C95E9BC0076A81A /* UIDelegate.mm in Sources */ = {isa = PBXBuildFile; fileRef = BCA51DE50C95E9BC0076A81A /* UIDelegate.mm */; };
+               BCA51F970C960CFC0076A81A /* LayoutTestControllerMac.mm in Sources */ = {isa = PBXBuildFile; fileRef = BCA51F960C960CFC0076A81A /* LayoutTestControllerMac.mm */; };
                BCA876B70C921FA100946E9C /* ObjCController.h in Headers */ = {isa = PBXBuildFile; fileRef = BCA876B50C921FA100946E9C /* ObjCController.h */; };
                BCA876B80C921FA100946E9C /* ObjCController.m in Sources */ = {isa = PBXBuildFile; fileRef = BCA876B60C921FA100946E9C /* ObjCController.m */; };
-               BCA877B00C93D8F500946E9C /* LayoutTestController.h in Headers */ = {isa = PBXBuildFile; fileRef = BCA877AE0C93D8F500946E9C /* LayoutTestController.h */; };
-               BCA877B10C93D8F500946E9C /* LayoutTestController.m in Sources */ = {isa = PBXBuildFile; fileRef = BCA877AF0C93D8F500946E9C /* LayoutTestController.m */; };
                D23AE9660C56BB2100C47236 /* PolicyDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = D23AE8EA0C56B2FF00C47236 /* PolicyDelegate.m */; };
                D23AE9690C56BB2900C47236 /* PolicyDelegate.h in Headers */ = {isa = PBXBuildFile; fileRef = D23AE8E00C56B29E00C47236 /* PolicyDelegate.h */; };
                E1330800099624DA00AC0A91 /* AppleScriptController.h in Headers */ = {isa = PBXBuildFile; fileRef = E13307FE099624DA00AC0A91 /* AppleScriptController.h */; };
 /* End PBXContainerItemProxy section */
 
 /* Begin PBXFileReference section */
-               08FB7796FE84155DC02AAC07 /* DumpRenderTree.m */ = {isa = PBXFileReference; explicitFileType = sourcecode.c.objc; fileEncoding = 4; path = DumpRenderTree.m; sourceTree = "<group>"; };
                141BF233096A44CF00E0753C /* TestNetscapePlugIn.plugin */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = TestNetscapePlugIn.plugin; sourceTree = BUILT_PRODUCTS_DIR; };
                141BF445096A45C800E0753C /* main.c */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.c; path = main.c; sourceTree = "<group>"; };
                141BF446096A45C800E0753C /* PluginObject.c */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.c; path = PluginObject.c; sourceTree = "<group>"; };
                141BF447096A45C800E0753C /* PluginObject.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = PluginObject.h; sourceTree = "<group>"; };
                141BF448096A45C800E0753C /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = text.xml; path = Info.plist; sourceTree = "<group>"; };
                1422A1B80AF6EDD600E1A883 /* UIDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = UIDelegate.h; sourceTree = "<group>"; };
-               1422A1B90AF6EDD600E1A883 /* UIDelegate.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = UIDelegate.m; sourceTree = "<group>"; };
                14770FE00A22ADF7009342EE /* GCController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = GCController.h; sourceTree = "<group>"; };
                14770FE10A22ADF7009342EE /* GCController.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = GCController.mm; sourceTree = "<group>"; };
                14A6FB880971CAE5008B014F /* NavigationController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = NavigationController.h; sourceTree = "<group>"; };
                22181BCF09DC8C4B008342E8 /* ObjCPluginFunction.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = ObjCPluginFunction.h; sourceTree = "<group>"; };
                22181BD009DC8C4B008342E8 /* ObjCPluginFunction.m */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.objc; path = ObjCPluginFunction.m; sourceTree = "<group>"; };
                32A70AAB03705E1F00C91783 /* DumpRenderTreePrefix.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DumpRenderTreePrefix.h; sourceTree = "<group>"; };
-               6508A26C0BFAB71B00AD2696 /* FrameLoadDelegate.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = FrameLoadDelegate.h; sourceTree = "<group>"; };
-               6508A26D0BFAB71B00AD2696 /* FrameLoadDelegate.m */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.objc; path = FrameLoadDelegate.m; sourceTree = "<group>"; };
+               6508A26C0BFAB71B00AD2696 /* FrameLoadDelegate.h */ = {isa = PBXFileReference; explicitFileType = sourcecode.c.h; fileEncoding = 30; path = FrameLoadDelegate.h; sourceTree = "<group>"; };
                9335435F03D75502008635CE /* WebKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; path = WebKit.framework; sourceTree = BUILT_PRODUCTS_DIR; };
                9340995408540CAF007F3BC8 /* DumpRenderTree */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = DumpRenderTree; sourceTree = BUILT_PRODUCTS_DIR; };
                93442CF408F8BA4900BFE8CA /* TextInputController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TextInputController.h; sourceTree = "<group>"; };
                B5A7525808AF4A3600138E45 /* ImageDiff.m */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.objc; path = ImageDiff.m; sourceTree = "<group>"; };
                B5A7526708AF4A4A00138E45 /* ImageDiff */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = ImageDiff; sourceTree = BUILT_PRODUCTS_DIR; };
                B5A752A108AF5D1F00138E45 /* QuartzCore.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = QuartzCore.framework; path = /System/Library/Frameworks/QuartzCore.framework; sourceTree = "<absolute>"; };
+               BC0131D80C9772010087317D /* LayoutTestController.cpp */ = {isa = PBXFileReference; explicitFileType = sourcecode.cpp.objcpp; fileEncoding = 30; path = LayoutTestController.cpp; sourceTree = "<group>"; };
+               BC0131D90C9772010087317D /* LayoutTestController.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = LayoutTestController.h; sourceTree = "<group>"; };
+               BC0131EE0C9774700087317D /* WorkQueueItemMac.mm */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.objcpp; path = WorkQueueItemMac.mm; sourceTree = "<group>"; };
+               BC9D90210C97472D0099A4A3 /* WorkQueue.cpp */ = {isa = PBXFileReference; explicitFileType = sourcecode.cpp.objcpp; fileEncoding = 30; path = WorkQueue.cpp; sourceTree = "<group>"; };
+               BC9D90220C97472E0099A4A3 /* WorkQueue.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = WorkQueue.h; sourceTree = "<group>"; };
+               BC9D90230C97472E0099A4A3 /* WorkQueueItem.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = WorkQueueItem.h; sourceTree = "<group>"; };
+               BCA51CFC0C95DFB30076A81A /* FrameLoadDelegate.mm */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.objcpp; path = FrameLoadDelegate.mm; sourceTree = "<group>"; };
+               BCA51D080C95DFE80076A81A /* DumpRenderTree.mm */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.objcpp; path = DumpRenderTree.mm; sourceTree = "<group>"; };
+               BCA51DE50C95E9BC0076A81A /* UIDelegate.mm */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.objcpp; path = UIDelegate.mm; sourceTree = "<group>"; };
+               BCA51F960C960CFC0076A81A /* LayoutTestControllerMac.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = LayoutTestControllerMac.mm; sourceTree = "<group>"; };
                BCA876B50C921FA100946E9C /* ObjCController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ObjCController.h; sourceTree = "<group>"; };
                BCA876B60C921FA100946E9C /* ObjCController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ObjCController.m; sourceTree = "<group>"; };
-               BCA877AE0C93D8F500946E9C /* LayoutTestController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = LayoutTestController.h; sourceTree = "<group>"; };
-               BCA877AF0C93D8F500946E9C /* LayoutTestController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = LayoutTestController.m; sourceTree = "<group>"; };
                D23AE8E00C56B29E00C47236 /* PolicyDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PolicyDelegate.h; sourceTree = "<group>"; };
                D23AE8EA0C56B2FF00C47236 /* PolicyDelegate.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = PolicyDelegate.m; sourceTree = "<group>"; };
                E13307FE099624DA00AC0A91 /* AppleScriptController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AppleScriptController.h; sourceTree = "<group>"; };
                                9345229B0BD12B2C0086EDA0 /* Resources */,
                                141BF1F5096A439800E0753C /* TestNetscapePlugIn.subproj */,
                                A803FF7409CAAD08009B2A37 /* DumpRenderTree.h */,
-                               08FB7796FE84155DC02AAC07 /* DumpRenderTree.m */,
+                               BCA51D080C95DFE80076A81A /* DumpRenderTree.mm */,
                                A803FFB209CAAE0B009B2A37 /* DumpRenderTreeDraggingInfo.h */,
                                A803FFB309CAAE0B009B2A37 /* DumpRenderTreeDraggingInfo.m */,
                                B5A7525808AF4A3600138E45 /* ImageDiff.m */,
                                22181BCE09DC8C4B008342E8 /* ObjCPlugin.m */,
                                22181BCF09DC8C4B008342E8 /* ObjCPluginFunction.h */,
                                22181BD009DC8C4B008342E8 /* ObjCPluginFunction.m */,
+                               BC9D90210C97472D0099A4A3 /* WorkQueue.cpp */,
+                               BC9D90220C97472E0099A4A3 /* WorkQueue.h */,
+                               BC9D90230C97472E0099A4A3 /* WorkQueueItem.h */,
+                               BC0131EE0C9774700087317D /* WorkQueueItemMac.mm */,
                                A803FF6409CAACC1009B2A37 /* Frameworks */,
                                9340995508540CAF007F3BC8 /* Products */,
                        );
                                93442CF508F8BA4900BFE8CA /* TextInputController.m */,
                                BCA876B50C921FA100946E9C /* ObjCController.h */,
                                BCA876B60C921FA100946E9C /* ObjCController.m */,
-                               BCA877AE0C93D8F500946E9C /* LayoutTestController.h */,
-                               BCA877AF0C93D8F500946E9C /* LayoutTestController.m */,
+                               BC0131D80C9772010087317D /* LayoutTestController.cpp */,
+                               BC0131D90C9772010087317D /* LayoutTestController.h */,
+                               BCA51F960C960CFC0076A81A /* LayoutTestControllerMac.mm */,
                        );
                        name = Controllers;
                        sourceTree = "<group>";
                        isa = PBXGroup;
                        children = (
                                6508A26C0BFAB71B00AD2696 /* FrameLoadDelegate.h */,
-                               6508A26D0BFAB71B00AD2696 /* FrameLoadDelegate.m */,
+                               BCA51CFC0C95DFB30076A81A /* FrameLoadDelegate.mm */,
                                A803FFF309CAAFE0009B2A37 /* EditingDelegate.h */,
                                A803FFF409CAAFE0009B2A37 /* EditingDelegate.m */,
                                D23AE8E00C56B29E00C47236 /* PolicyDelegate.h */,
                                1A6CA8630B7120CF00A24B62 /* ResourceLoadDelegate.h */,
                                1A6CA8640B7120CF00A24B62 /* ResourceLoadDelegate.m */,
                                1422A1B80AF6EDD600E1A883 /* UIDelegate.h */,
-                               1422A1B90AF6EDD600E1A883 /* UIDelegate.m */,
+                               BCA51DE50C95E9BC0076A81A /* UIDelegate.mm */,
                        );
                        name = Delegates;
                        sourceTree = "<group>";
                                6508A29A0BFABB8200AD2696 /* ResourceLoadDelegate.h in Headers */,
                                D23AE9690C56BB2900C47236 /* PolicyDelegate.h in Headers */,
                                BCA876B70C921FA100946E9C /* ObjCController.h in Headers */,
-                               BCA877B00C93D8F500946E9C /* LayoutTestController.h in Headers */,
+                               BC9D90250C97472E0099A4A3 /* WorkQueue.h in Headers */,
+                               BC9D90260C97472E0099A4A3 /* WorkQueueItem.h in Headers */,
+                               BC0131DB0C9772010087317D /* LayoutTestController.h in Headers */,
                        );
                        runOnlyForDeploymentPostprocessing = 0;
                };
                        files = (
                                A803FFBD09CAAE99009B2A37 /* DumpRenderTreeDraggingInfo.m in Sources */,
                                A803FCC709CAAB8D009B2A37 /* EventSendingController.m in Sources */,
-                               9340994E08540CAE007F3BC8 /* DumpRenderTree.m in Sources */,
                                93442CF708F8BA4900BFE8CA /* TextInputController.m in Sources */,
                                14A6FB8B0971CAE5008B014F /* NavigationController.m in Sources */,
                                E1330801099624DA00AC0A91 /* AppleScriptController.m in Sources */,
                                22181BD409DC8C4B008342E8 /* ObjCPluginFunction.m in Sources */,
                                14770FE30A22ADF7009342EE /* GCController.mm in Sources */,
                                1A6CA8DE0B7122D100A24B62 /* ResourceLoadDelegate.m in Sources */,
-                               1422A1BB0AF6EDD600E1A883 /* UIDelegate.m in Sources */,
-                               6508A2980BFABB8000AD2696 /* FrameLoadDelegate.m in Sources */,
                                D23AE9660C56BB2100C47236 /* PolicyDelegate.m in Sources */,
                                BCA876B80C921FA100946E9C /* ObjCController.m in Sources */,
-                               BCA877B10C93D8F500946E9C /* LayoutTestController.m in Sources */,
+                               BCA51CFD0C95DFB30076A81A /* FrameLoadDelegate.mm in Sources */,
+                               BCA51D090C95DFE80076A81A /* DumpRenderTree.mm in Sources */,
+                               BCA51DE60C95E9BC0076A81A /* UIDelegate.mm in Sources */,
+                               BCA51F970C960CFC0076A81A /* LayoutTestControllerMac.mm in Sources */,
+                               BC9D90240C97472E0099A4A3 /* WorkQueue.cpp in Sources */,
+                               BC0131DA0C9772010087317D /* LayoutTestController.cpp in Sources */,
+                               BC0131EF0C9774700087317D /* WorkQueueItemMac.mm in Sources */,
                        );
                        runOnlyForDeploymentPostprocessing = 0;
                };
index a025803..18766bd 100644 (file)
 
 #import <Cocoa/Cocoa.h>
 
+class LayoutTestController; 
 
-@interface FrameLoadDelegate : NSObject {
+@interface FrameLoadDelegate : NSObject
+{
+    LayoutTestController* layoutTestContoller;
 }
-
 @end
 #import "ObjCPlugin.h"
 #import "ObjCPluginFunction.h"
 #import "TextInputController.h"
-
+#import "WorkQueue.h"
+#import "WorkQueueItem.h"
 #import <JavaScriptCore/Assertions.h>
 #import <JavaScriptCore/JavaScriptCore.h>
-#import <WebKit/WebKit.h>
-#import <WebKit/WebHTMLViewPrivate.h>
 #import <WebKit/WebFramePrivate.h>
+#import <WebKit/WebHTMLViewPrivate.h>
+#import <WebKit/WebKit.h>
 #import <WebKit/WebNSURLExtras.h>
 
 @interface NSURLRequest (PrivateThingsWeShouldntReallyUse)
 
 @implementation FrameLoadDelegate
 
+- (id)init
+{
+    layoutTestContoller = new LayoutTestController();
+    return [super init];
+}
+
+- (void)dealloc
+{
+    delete layoutTestContoller;
+    [super dealloc];
+}
+
 // Exec messages in the work queue until they're all done, or one of them starts a new load
 - (void)processWork:(id)dummy
 {
     // quit doing work once a load is in progress
-    while ([workQueue count] > 0 && !topLoadingFrame) {
-        [[workQueue objectAtIndex:0] invoke];
-        [workQueue removeObjectAtIndex:0];
+    while (WorkQueue::shared()->count() > 0 && !topLoadingFrame) {
+        WorkQueueItem* item = WorkQueue::shared()->dequeue();
+        ASSERT(item);
+        item->invoke();
     }
     
     // if we didn't start a new load, then we finished all the commands, so we're ready to dump state
 {
     if ([dataSource webFrame] == topLoadingFrame) {
         topLoadingFrame = nil;
-        workQueueFrozen = YES;      // first complete load freezes the queue for the rest of this test
+        WorkQueue::shared()->setFrozen(true); // first complete load freezes the queue for the rest of this test
         if (!waitToDump) {
-            if ([workQueue count] > 0)
+            if (WorkQueue::shared()->count())
                 [self performSelector:@selector(processWork:) withObject:nil afterDelay:0];
             else
                 dump();
         
     ASSERT(obj == [frame windowObject]);
     ASSERT([obj JSObject] == JSContextGetGlobalObject([frame globalContext]));
-    
-    LayoutTestController *ltc = [[LayoutTestController alloc] init];
-    [obj setValue:ltc forKey:@"layoutTestController"];
-    [ltc release];
-    
+
+    // Make New-Style LayoutTestController
+    JSContextRef context = [frame globalContext];
+    JSObjectRef globalObject = JSContextGetGlobalObject(context);
+    JSValueRef exception = 0;
+    layoutTestContoller->makeWindowObject(context, globalObject, &exception);
+    ASSERT(!exception);
+
+    // Make Old-Style controllers
     EventSendingController *esc = [[EventSendingController alloc] init];
     [obj setValue:esc forKey:@"eventSender"];
     [esc release];
diff --git a/WebKitTools/DumpRenderTree/LayoutTestController.cpp b/WebKitTools/DumpRenderTree/LayoutTestController.cpp
new file mode 100644 (file)
index 0000000..3d9131a
--- /dev/null
@@ -0,0 +1,517 @@
+/*
+ * Copyright (C) 2007 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1.  Redistributions of source code must retain the above copyright
+ *     notice, this list of conditions and the following disclaimer. 
+ * 2.  Redistributions in binary form must reproduce the above copyright
+ *     notice, this list of conditions and the following disclaimer in the
+ *     documentation and/or other materials provided with the distribution. 
+ * 3.  Neither the name of Apple Computer, Inc. ("Apple") nor the names of
+ *     its contributors may be used to endorse or promote products derived
+ *     from this software without specific prior written permission. 
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "LayoutTestController.h"
+
+#include "DumpRenderTree.h"
+#include <JavaScriptCore/Assertions.h>
+#include <JavaScriptCore/JSObjectRef.h>
+#include <JavaScriptCore/JSRetainPtr.h>
+
+LayoutTestController::LayoutTestController()
+{
+}
+
+LayoutTestController::~LayoutTestController()
+{
+}
+
+#pragma mark -
+#pragma mark Static Functions
+
+static JSValueRef dumpAsTextCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
+{
+    LayoutTestController* controller = reinterpret_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
+    controller->dumpAsText();
+    return JSValueMakeUndefined(context);
+}
+
+static JSValueRef dumpBackForwardListCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
+{
+    LayoutTestController* controller = reinterpret_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
+    controller->dumpBackForwardList();
+    return JSValueMakeUndefined(context);
+}
+
+static JSValueRef dumpChildFramesAsTextCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
+{
+    LayoutTestController* controller = reinterpret_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
+    controller->dumpChildFramesAsText();
+    return JSValueMakeUndefined(context);
+}
+
+static JSValueRef dumpChildFrameScrollPositionsCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
+{
+    LayoutTestController* controller = reinterpret_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
+    controller->dumpChildFrameScrollPositions();
+    return JSValueMakeUndefined(context);
+}
+
+static JSValueRef dumpDOMAsWebArchiveCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
+{
+    LayoutTestController* controller = reinterpret_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
+    controller->dumpDOMAsWebArchive();
+    return JSValueMakeUndefined(context);
+}
+
+static JSValueRef dumpEditingCallbacksCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
+{
+    LayoutTestController* controller = reinterpret_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
+    controller->dumpEditingCallbacks();
+    return JSValueMakeUndefined(context);
+}
+
+static JSValueRef dumpFrameLoadCallbacksCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
+{
+    LayoutTestController* controller = reinterpret_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
+    controller->dumpFrameLoadCallbacks();
+    return JSValueMakeUndefined(context);
+}
+
+static JSValueRef dumpResourceLoadCallbacksCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
+{
+    LayoutTestController* controller = reinterpret_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
+    controller->dumpResourceLoadCallbacks();
+    return JSValueMakeUndefined(context);
+}
+
+static JSValueRef dumpSelectionRectCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
+{
+    LayoutTestController* controller = reinterpret_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
+    controller->dumpSelectionRect();
+    return JSValueMakeUndefined(context);
+}
+
+static JSValueRef dumpSourceAsWebArchiveCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
+{
+    LayoutTestController* controller = reinterpret_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
+    controller->dumpSourceAsWebArchive();
+    return JSValueMakeUndefined(context);
+}
+
+static JSValueRef dumpTitleChangesCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
+{
+    LayoutTestController* controller = reinterpret_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
+    controller->dumpTitleChanges();
+    return JSValueMakeUndefined(context);
+}
+
+static JSValueRef repaintSweepHorizontallyCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
+{
+    repaintSweepHorizontally = true;
+    return JSValueMakeUndefined(context);
+}
+
+static JSValueRef setCallCloseOnWebViewsCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
+{
+    if (argumentCount < 1)
+        return JSValueMakeUndefined(context);
+
+    closeWebViews = JSValueToBoolean(context, arguments[0]);
+    return JSValueMakeUndefined(context);
+}
+
+static JSValueRef setCanOpenWindowsCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
+{
+    canOpenWindows = true;
+    return JSValueMakeUndefined(context);
+}
+
+static JSValueRef setCloseRemainingWindowsWhenCompleteCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
+{
+    if (argumentCount < 1)
+        return JSValueMakeUndefined(context);
+
+    closeRemainingWindowsWhenComplete = JSValueToBoolean(context, arguments[0]);
+    return JSValueMakeUndefined(context);
+}
+
+static JSValueRef testRepaintCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
+{
+    testRepaint = true;
+    return JSValueMakeUndefined(context);
+}
+
+static JSValueRef addFileToPasteboardOnDragCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
+{
+    addFileToPasteboardOnDrag = YES;
+    return JSValueMakeUndefined(context);
+}
+
+#pragma mark Require implementation
+
+static JSValueRef addDisallowedURLCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
+{
+    // Has mac implementation
+    if (argumentCount < 1)
+        return JSValueMakeUndefined(context);
+
+    JSRetainPtr<JSStringRef> url(Adopt, JSValueToStringCopy(context, arguments[0], exception));
+    ASSERT(!*exception);
+
+    LayoutTestController* controller = reinterpret_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
+    controller->addDisallowedURL(url.get());
+
+    return JSValueMakeUndefined(context);
+}
+
+static JSValueRef clearBackForwardListCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
+{
+    // Has mac & windows implementation
+    LayoutTestController* controller = reinterpret_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
+    controller->clearBackForwardList();
+
+    return JSValueMakeUndefined(context);
+}
+
+static JSValueRef decodeHostNameCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
+{
+    // Has mac implementation
+    if (argumentCount < 1)
+        return JSValueMakeUndefined(context);
+
+    JSRetainPtr<JSStringRef> name(Adopt, JSValueToStringCopy(context, arguments[0], exception));
+    ASSERT(!*exception);
+
+    LayoutTestController* controller = reinterpret_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
+    return JSValueMakeString(context, controller->decodeHostName(name.get()));
+}
+
+static JSValueRef displayCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
+{
+    // Has mac & windows implementation
+    LayoutTestController* controller = reinterpret_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
+    controller->display();
+
+    return JSValueMakeUndefined(context);
+}
+
+static JSValueRef encodeHostNameCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
+{
+    // Has mac implementation
+    if (argumentCount < 1)
+        return JSValueMakeUndefined(context);
+
+    JSRetainPtr<JSStringRef> name(Adopt, JSValueToStringCopy(context, arguments[0], exception));
+    ASSERT(!*exception);
+
+    LayoutTestController* controller = reinterpret_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
+    return JSValueMakeString(context, controller->encodeHostName(name.get()));
+}
+
+static JSValueRef keepWebHistoryCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
+{
+    // Has mac implementation
+    LayoutTestController* controller = reinterpret_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
+    controller->keepWebHistory();
+
+    return JSValueMakeUndefined(context);
+}
+
+static JSValueRef notifyDoneCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
+{
+    // Has mac & windows implementation
+    // May be able to be made platform independant by using shared WorkQueue
+    LayoutTestController* controller = reinterpret_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
+    controller->notifyDone();
+
+    return JSValueMakeUndefined(context);
+}
+
+static JSValueRef queueBackNavigationCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
+{
+    // Has mac & windows implementation
+    // May be able to be made platform independant by using shared WorkQueue
+    if (argumentCount < 1)
+        return JSValueMakeUndefined(context);
+
+    double howFarBackDouble = JSValueToNumber(context, arguments[0], exception);
+    ASSERT(!*exception);
+
+    LayoutTestController* controller = reinterpret_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
+    controller->queueBackNavigation(static_cast<int>(howFarBackDouble));
+
+    return JSValueMakeUndefined(context);
+}
+
+static JSValueRef queueForwardNavigationCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
+{
+    // Has mac & windows implementation
+    // May be able to be made platform independant by using shared WorkQueue
+    if (argumentCount < 1)
+        return JSValueMakeUndefined(context);
+
+    double howFarForwardDouble = JSValueToNumber(context, arguments[0], exception);
+    ASSERT(!*exception);
+
+    LayoutTestController* controller = reinterpret_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
+    controller->queueForwardNavigation(static_cast<int>(howFarForwardDouble));
+
+    return JSValueMakeUndefined(context);
+}
+
+static JSValueRef queueLoadCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
+{
+    // Has mac & windows implementation
+    // May be able to be made platform independant by using shared WorkQueue
+    if (argumentCount < 1)
+        return JSValueMakeUndefined(context);
+
+    JSRetainPtr<JSStringRef> url(Adopt, JSValueToStringCopy(context, arguments[0], exception));
+    ASSERT(!*exception);
+
+    JSRetainPtr<JSStringRef> target;
+    if (argumentCount >= 2) {
+        target.adopt(JSValueToStringCopy(context, arguments[1], exception));
+        ASSERT(!*exception);
+    } else
+        target.adopt(JSStringCreateWithUTF8CString(""));
+
+    LayoutTestController* controller = reinterpret_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
+    controller->queueLoad(url.get(), target.get());
+
+    return JSValueMakeUndefined(context);
+}
+
+static JSValueRef queueReloadCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
+{
+    // Has mac & windows implementation
+    // May be able to be made platform independant by using shared WorkQueue
+
+    LayoutTestController* controller = reinterpret_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
+    controller->queueReload();
+
+    return JSValueMakeUndefined(context);
+}
+
+static JSValueRef queueScriptCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
+{
+    // Has mac & windows implementation
+    // May be able to be made platform independant by using shared WorkQueue
+    if (argumentCount < 1)
+        return JSValueMakeUndefined(context);
+
+    JSRetainPtr<JSStringRef> script(Adopt, JSValueToStringCopy(context, arguments[0], exception));
+    ASSERT(!*exception);
+
+    LayoutTestController* controller = reinterpret_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
+    controller->queueScript(script.get());
+
+    return JSValueMakeUndefined(context);
+}
+
+static JSValueRef setAcceptsEditingCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
+{
+    // Has mac & windows implementation
+    if (argumentCount < 1)
+        return JSValueMakeUndefined(context);
+
+    LayoutTestController* controller = reinterpret_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
+    controller->setAcceptsEditing(JSValueToBoolean(context, arguments[0]));
+
+    return JSValueMakeUndefined(context);
+}
+
+static JSValueRef setCustomPolicyDelegateCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
+{
+    // Has mac implementation
+    if (argumentCount < 1)
+        return JSValueMakeUndefined(context);
+
+    LayoutTestController* controller = reinterpret_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
+    controller->setCustomPolicyDelegate(JSValueToBoolean(context, arguments[0]));
+
+    return JSValueMakeUndefined(context);
+}
+
+static JSValueRef setMainFrameIsFirstResponderCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
+{
+    // Has mac implementation
+    if (argumentCount < 1)
+        return JSValueMakeUndefined(context);
+
+    LayoutTestController* controller = reinterpret_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
+    controller->setMainFrameIsFirstResponder(JSValueToBoolean(context, arguments[0]));
+
+    return JSValueMakeUndefined(context);
+}
+
+static JSValueRef setTabKeyCyclesThroughElementsCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
+{
+    // Has mac & windows implementation
+    if (argumentCount < 1)
+        return JSValueMakeUndefined(context);
+
+    LayoutTestController* controller = reinterpret_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
+    controller->setTabKeyCyclesThroughElements(JSValueToBoolean(context, arguments[0]));
+
+    return JSValueMakeUndefined(context);
+}
+
+static JSValueRef setUseDashboardCompatibilityModeCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
+{
+    // Has mac implementation
+    if (argumentCount < 1)
+        return JSValueMakeUndefined(context);
+
+    LayoutTestController* controller = reinterpret_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
+    controller->setUseDashboardCompatibilityMode(JSValueToBoolean(context, arguments[0]));
+
+    return JSValueMakeUndefined(context);
+}
+
+static JSValueRef setUserStyleSheetEnabledCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
+{
+    // Has mac implementation
+    if (argumentCount < 1)
+        return JSValueMakeUndefined(context);
+
+    LayoutTestController* controller = reinterpret_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
+    controller->setUserStyleSheetEnabled(JSValueToBoolean(context, arguments[0]));
+
+    return JSValueMakeUndefined(context);
+}
+
+static JSValueRef setUserStyleSheetLocationCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
+{
+    // Has mac implementation
+    if (argumentCount < 1)
+        return JSValueMakeUndefined(context);
+
+    JSRetainPtr<JSStringRef> path(Adopt, JSValueToStringCopy(context, arguments[0], exception));
+    ASSERT(!*exception);
+
+    LayoutTestController* controller = reinterpret_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
+    controller->setUserStyleSheetLocation(path.get());
+
+    return JSValueMakeUndefined(context);
+}
+
+static JSValueRef setWindowIsKeyCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
+{
+    // Has mac implementation
+    if (argumentCount < 1)
+        return JSValueMakeUndefined(context);
+
+    LayoutTestController* controller = reinterpret_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
+    controller->setWindowIsKey(JSValueToBoolean(context, arguments[0]));
+
+    return JSValueMakeUndefined(context);
+}
+
+static JSValueRef waitUntilDoneCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
+{
+    // Has mac & windows implementation
+    LayoutTestController* controller = reinterpret_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
+    controller->waitUntilDone();
+
+    return JSValueMakeUndefined(context);
+}
+
+static JSValueRef windowCountCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
+{
+    // Has mac implementation
+    LayoutTestController* controller = reinterpret_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
+    int windows = controller->windowCount();
+    return JSValueMakeNumber(context, windows);
+}
+
+#pragma mark -
+#pragma mark Object Creation
+
+void LayoutTestController::makeWindowObject(JSContextRef context, JSObjectRef windowObject, JSValueRef* exception)
+{
+    JSRetainPtr<JSStringRef> layoutTestContollerStr(Adopt, JSStringCreateWithUTF8CString("layoutTestController"));
+    JSValueRef layoutTestContollerObject = JSObjectMake(context, getLayoutTestControllerJSClass(), this);
+    JSObjectSetProperty(context, windowObject, layoutTestContollerStr.get(), layoutTestContollerObject, kJSPropertyAttributeNone, exception);
+}
+
+JSClassRef LayoutTestController::getLayoutTestControllerJSClass()
+{
+    static JSClassRef layoutTestControllerClass = 0;
+
+    if (!layoutTestControllerClass) {
+        JSStaticFunction* staticFunctions = LayoutTestController::staticFunctions();
+        JSClassDefinition classDefinition = {
+            0, kJSClassAttributeNone, "LayoutTestController", 0, 0, staticFunctions,
+            0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
+        };
+
+        layoutTestControllerClass = JSClassCreate(&classDefinition);
+    }
+
+    return layoutTestControllerClass;
+}
+
+JSStaticFunction* LayoutTestController::staticFunctions()
+{
+    static JSStaticFunction staticFunctions[] = {
+        { "addDisallowedURL", addDisallowedURLCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
+        { "addFileToPasteboardOnDrag", addFileToPasteboardOnDragCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
+        { "clearBackForwardList", clearBackForwardListCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
+        { "decodeHostName", decodeHostNameCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
+        { "display", displayCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
+        { "dumpAsText", dumpAsTextCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
+        { "dumpBackForwardList", dumpBackForwardListCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
+        { "dumpChildFramesAsText", dumpChildFramesAsTextCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
+        { "dumpChildFrameScrollPositions", dumpChildFrameScrollPositionsCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
+        { "dumpDOMAsWebArchive", dumpDOMAsWebArchiveCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
+        { "dumpEditingCallbacks", dumpEditingCallbacksCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
+        { "dumpFrameLoadCallbacks", dumpFrameLoadCallbacksCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
+        { "dumpResourceLoadCallbacks", dumpResourceLoadCallbacksCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
+        { "dumpSelectionRect", dumpSelectionRectCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
+        { "dumpSourceAsWebArchive", dumpSourceAsWebArchiveCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
+        { "dumpTitleChanges", dumpTitleChangesCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
+        { "encodeHostName", encodeHostNameCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
+        { "keepWebHistory", keepWebHistoryCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
+        { "notifyDone", notifyDoneCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
+        { "queueBackNavigation", queueBackNavigationCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
+        { "queueForwardNavigation", queueForwardNavigationCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
+        { "queueLoad", queueLoadCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
+        { "queueReload", queueReloadCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
+        { "queueScript", queueScriptCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
+        { "repaintSweepHorizontally", repaintSweepHorizontallyCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
+        { "setAcceptsEditing", setAcceptsEditingCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
+        { "setCallCloseOnWebViews", setCallCloseOnWebViewsCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
+        { "setCanOpenWindows", setCanOpenWindowsCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
+        { "setCloseRemainingWindowsWhenComplete", setCloseRemainingWindowsWhenCompleteCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
+        { "setCustomPolicyDelegate", setCustomPolicyDelegateCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
+        { "setMainFrameIsFirstResponder", setMainFrameIsFirstResponderCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
+        { "setTabKeyCyclesThroughElements", setTabKeyCyclesThroughElementsCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
+        { "setUseDashboardCompatibilityMode", setUseDashboardCompatibilityModeCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
+        { "setUserStyleSheetEnabled", setUserStyleSheetEnabledCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
+        { "setUserStyleSheetLocation", setUserStyleSheetLocationCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
+        { "setWindowIsKey", setWindowIsKeyCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
+        { "testRepaint", testRepaintCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
+        { "waitUntilDone", waitUntilDoneCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
+        { "windowCount", windowCountCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
+        { 0, 0, 0 }
+    };
+
+    return staticFunctions;
+}
index 8a1d57d..53c8cd3 100644 (file)
  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
+#ifndef LayoutTestController_h
+#define LayoutTestController_h
 
-#import <Foundation/Foundation.h>
+#include <JavaScriptCore/JSObjectRef.h>
 
-@class WebScriptObject;
+class LayoutTestController {
+public:
+    LayoutTestController();
+    ~LayoutTestController();
 
-@interface LayoutTestController : NSObject
-{
-    WebScriptObject *storedWebScriptObject;
-}
-- (void)dealloc;
-@end
+    void makeWindowObject(JSContextRef context, JSObjectRef windowObject, JSValueRef* exception);
+
+    // Controller Methods - platfrom independant implementations
+    void dumpAsText();
+    void dumpBackForwardList();
+    void dumpChildFramesAsText();
+    void dumpChildFrameScrollPositions();
+    void dumpDOMAsWebArchive();
+    void dumpEditingCallbacks();
+    void dumpFrameLoadCallbacks();
+    void dumpResourceLoadCallbacks();
+    void dumpSelectionRect();
+    void dumpSourceAsWebArchive();
+    void dumpTitleChanges();
+    void repaintSweepHorizontally();
+    void setCallCloseOnWebViews();
+    void setCanOpenWindows();
+    void setCloseRemainingWindowsWhenComplete();
+    void testRepaint();
+    void addFileToPasteboardOnDrag();
+    void addDisallowedURL(JSStringRef url);
+    void clearBackForwardList();
+    JSStringRef decodeHostName(JSStringRef name);
+    JSStringRef encodeHostName(JSStringRef name);
+    void display();
+    void keepWebHistory();
+    void notifyDone();
+    void queueBackNavigation(int howFarBackward);
+    void queueForwardNavigation(int howFarForward);
+    void queueLoad(JSStringRef url, JSStringRef target);
+    void queueReload();
+    void queueScript(JSStringRef url);
+    void setAcceptsEditing(bool acceptsEditing);
+    void setCustomPolicyDelegate(bool setDelegate);
+    void setMainFrameIsFirstResponder(bool flag);
+    void setTabKeyCyclesThroughElements(bool cycles);
+    void setUseDashboardCompatibilityMode(bool flag);
+    void setUserStyleSheetEnabled(bool flag);
+    void setUserStyleSheetLocation(JSStringRef path);
+    void setWindowIsKey(bool flag);
+    void waitUntilDone();
+    int windowCount();
+
+
+private:
+    static JSClassRef getLayoutTestControllerJSClass();
+    static JSStaticFunction* staticFunctions();
+};
+
+#endif // LayoutTestController_h
diff --git a/WebKitTools/DumpRenderTree/LayoutTestController.m b/WebKitTools/DumpRenderTree/LayoutTestController.m
deleted file mode 100644 (file)
index 2575e3c..0000000
+++ /dev/null
@@ -1,457 +0,0 @@
-/*
- * Copyright (C) 2006 Apple Computer, Inc.  All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1.  Redistributions of source code must retain the above copyright
- *     notice, this list of conditions and the following disclaimer. 
- * 2.  Redistributions in binary form must reproduce the above copyright
- *     notice, this list of conditions and the following disclaimer in the
- *     documentation and/or other materials provided with the distribution. 
- * 3.  Neither the name of Apple Computer, Inc. ("Apple") nor the names of
- *     its contributors may be used to endorse or promote products derived
- *     from this software without specific prior written permission. 
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
- * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#import "LayoutTestController.h"
-
-#import "DumpRenderTree.h"
-
-#import <JavaScriptCore/Assertions.h>
-#import <WebKit/WebBackForwardList.h>
-#import <WebKit/WebFrame.h>
-#import <WebKit/WebHTMLView.h>
-#import <WebKit/WebHTMLViewPrivate.h>
-#import <WebKit/WebHistory.h>
-#import <WebKit/WebNSURLExtras.h>
-#import <WebKit/WebPreferences.h>
-#import <WebKit/WebScriptObject.h>
-#import <WebKit/WebView.h>
-#import <WebKit/WebViewPrivate.h>
-
-@implementation LayoutTestController
-
-+ (BOOL)isSelectorExcludedFromWebScript:(SEL)aSelector
-{
-    if (0
-            || aSelector == @selector(accessStoredWebScriptObject)
-            || aSelector == @selector(addDisallowedURL:)    
-            || aSelector == @selector(addFileToPasteboardOnDrag)
-            || aSelector == @selector(clearBackForwardList)
-            || aSelector == @selector(decodeHostName:)
-            || aSelector == @selector(display)
-            || aSelector == @selector(dumpAsText)
-            || aSelector == @selector(dumpBackForwardList)
-            || aSelector == @selector(dumpChildFrameScrollPositions)
-            || aSelector == @selector(dumpChildFramesAsText)
-            || aSelector == @selector(dumpDOMAsWebArchive)
-            || aSelector == @selector(dumpEditingCallbacks)
-            || aSelector == @selector(dumpFrameLoadCallbacks)
-            || aSelector == @selector(dumpResourceLoadCallbacks)
-            || aSelector == @selector(dumpSelectionRect)
-            || aSelector == @selector(dumpSourceAsWebArchive)
-            || aSelector == @selector(dumpTitleChanges)
-            || aSelector == @selector(encodeHostName:)
-            || aSelector == @selector(keepWebHistory)
-            || aSelector == @selector(notifyDone)
-            || aSelector == @selector(queueBackNavigation:)
-            || aSelector == @selector(queueForwardNavigation:)
-            || aSelector == @selector(queueLoad:target:)
-            || aSelector == @selector(queueReload)
-            || aSelector == @selector(queueScript:)
-            || aSelector == @selector(repaintSweepHorizontally)
-            || aSelector == @selector(setAcceptsEditing:)
-            || aSelector == @selector(setCallCloseOnWebViews:)
-            || aSelector == @selector(setCanOpenWindows)
-            || aSelector == @selector(setCloseRemainingWindowsWhenComplete:)
-            || aSelector == @selector(setCustomPolicyDelegate:)
-            || aSelector == @selector(setMainFrameIsFirstResponder:)
-            || aSelector == @selector(setTabKeyCyclesThroughElements:)
-            || aSelector == @selector(setUseDashboardCompatibilityMode:)
-            || aSelector == @selector(setUserStyleSheetEnabled:)
-            || aSelector == @selector(setUserStyleSheetLocation:)
-            || aSelector == @selector(setWindowIsKey:)
-            || aSelector == @selector(storeWebScriptObject:)
-            || aSelector == @selector(testRepaint)
-            || aSelector == @selector(waitUntilDone)
-            || aSelector == @selector(windowCount)
-        )
-        return NO;
-    return YES;
-}
-
-+ (NSString *)webScriptNameForSelector:(SEL)aSelector
-{
-    if (aSelector == @selector(setWindowIsKey:))
-        return @"setWindowIsKey";
-    if (aSelector == @selector(setMainFrameIsFirstResponder:))
-        return @"setMainFrameIsFirstResponder";
-    if (aSelector == @selector(queueBackNavigation:))
-        return @"queueBackNavigation";
-    if (aSelector == @selector(queueForwardNavigation:))
-        return @"queueForwardNavigation";
-    if (aSelector == @selector(queueScript:))
-        return @"queueScript";
-    if (aSelector == @selector(queueLoad:target:))
-        return @"queueLoad";
-    if (aSelector == @selector(setAcceptsEditing:))
-        return @"setAcceptsEditing";
-    if (aSelector == @selector(setTabKeyCyclesThroughElements:))
-        return @"setTabKeyCyclesThroughElements";
-    if (aSelector == @selector(storeWebScriptObject:))
-        return @"storeWebScriptObject";
-    if (aSelector == @selector(setUserStyleSheetLocation:))
-        return @"setUserStyleSheetLocation";
-    if (aSelector == @selector(setUserStyleSheetEnabled:))
-        return @"setUserStyleSheetEnabled";
-    if (aSelector == @selector(addDisallowedURL:))
-        return @"addDisallowedURL";
-    if (aSelector == @selector(setCallCloseOnWebViews:))
-        return @"setCallCloseOnWebViews";
-    if (aSelector == @selector(setCloseRemainingWindowsWhenComplete:))
-        return @"setCloseRemainingWindowsWhenComplete";
-    if (aSelector == @selector(setCustomPolicyDelegate:))
-        return @"setCustomPolicyDelegate";
-    if (aSelector == @selector(setUseDashboardCompatibilityMode:))
-        return @"setUseDashboardCompatiblityMode";
-    if (aSelector == @selector(encodeHostName:))
-        return @"encodeHostName";
-    if (aSelector == @selector(decodeHostName:))
-        return @"decodeHostName";    
-    
-    return nil;
-}
-
-- (void)clearBackForwardList
-{
-    WebBackForwardList *backForwardList = [[mainFrame webView] backForwardList];
-    WebHistoryItem *item = [[backForwardList currentItem] retain];
-
-    // We clear the history by setting the back/forward list's capacity to 0
-    // then restoring it back and adding back the current item.
-    int capacity = [backForwardList capacity];
-    [backForwardList setCapacity:0];
-    [backForwardList setCapacity:capacity];
-    [backForwardList addItem:item];
-    [backForwardList goToItem:item];
-    [item release];
-}
-
-- (void)setUseDashboardCompatibilityMode:(BOOL)flag
-{
-    [[mainFrame webView] _setDashboardBehavior:WebDashboardBehaviorUseBackwardCompatibilityMode to:flag];
-}
-
-- (void)setCloseRemainingWindowsWhenComplete:(BOOL)closeWindows
-{
-    closeRemainingWindowsWhenComplete = closeWindows;
-}
-
-- (void)setCustomPolicyDelegate:(BOOL)setDelegate
-{
-    if (setDelegate)
-        [[mainFrame webView] setPolicyDelegate:policyDelegate];
-    else
-        [[mainFrame webView] setPolicyDelegate:nil];
-}
-
-- (void)keepWebHistory
-{
-    if (![WebHistory optionalSharedHistory]) {
-        WebHistory *history = [[WebHistory alloc] init];
-        [WebHistory setOptionalSharedHistory:history];
-        [history release];
-    }
-}
-
-- (void)setCallCloseOnWebViews:(BOOL)callClose
-{
-    closeWebViews = callClose;
-}
-
-- (void)setCanOpenWindows
-{
-    canOpenWindows = YES;
-}
-
-- (void)waitUntilDone
-{
-    waitToDump = YES;
-    if (!waitToDumpWatchdog)
-        waitToDumpWatchdog = [[NSTimer scheduledTimerWithTimeInterval:waitToDumpWatchdogInterval target:self selector:@selector(waitUntilDoneWatchdogFired) userInfo:nil repeats:NO] retain];
-}
-
-- (void)waitUntilDoneWatchdogFired
-{
-    const char* message = "FAIL: Timed out waiting for notifyDone to be called\n";
-    fprintf(stderr, message);
-    fprintf(stdout, message);
-    dump();
-}
-
-- (void)notifyDone
-{
-    if (waitToDump && !topLoadingFrame && [workQueue count] == 0)
-        dump();
-    waitToDump = NO;
-}
-
-- (void)dumpAsText
-{
-    dumpAsText = YES;
-}
-
-- (void)addFileToPasteboardOnDrag
-{
-    addFileToPasteboardOnDrag = YES;
-}
-
-- (void)addDisallowedURL:(NSString *)urlString
-{
-    if (!disallowedURLs)
-        disallowedURLs = [[NSMutableSet alloc] init];
-    
-    
-    // Canonicalize the URL
-    NSURLRequest* request = [NSURLRequest requestWithURL:[NSURL URLWithString:urlString]];
-    request = [NSURLProtocol canonicalRequestForRequest:request];
-    
-    [disallowedURLs addObject:[request URL]];
-}
-
-- (void)setUserStyleSheetLocation:(NSString *)path
-{
-    NSURL *url = [NSURL URLWithString:path];
-    [[WebPreferences standardPreferences] setUserStyleSheetLocation:url];
-}
-
-- (void)setUserStyleSheetEnabled:(BOOL)flag
-{
-    [[WebPreferences standardPreferences] setUserStyleSheetEnabled:flag];
-}
-
-- (void)dumpDOMAsWebArchive
-{
-    dumpDOMAsWebArchive = YES;
-}
-
-- (void)dumpSourceAsWebArchive
-{
-    dumpSourceAsWebArchive = YES;
-}
-
-- (void)dumpSelectionRect
-{
-    dumpSelectionRect = YES;
-}
-
-- (void)dumpTitleChanges
-{
-    dumpTitleChanges = YES;
-}
-
-- (void)dumpBackForwardList
-{
-    dumpBackForwardList = YES;
-}
-
-- (int)windowCount
-{
-    return CFArrayGetCount(allWindowsRef);
-}
-
-- (void)dumpChildFrameScrollPositions
-{
-    dumpChildFrameScrollPositions = YES;
-}
-
-- (void)dumpChildFramesAsText
-{
-    dumpChildFramesAsText = YES;
-}
-
-- (void)dumpEditingCallbacks
-{
-    shouldDumpEditingCallbacks = YES;
-}
-
-- (void)dumpResourceLoadCallbacks
-{
-    shouldDumpResourceLoadCallbacks = YES;
-}
-
-- (void)dumpFrameLoadCallbacks
-{
-    shouldDumpFrameLoadCallbacks = YES;
-}
-
-- (void)setWindowIsKey:(BOOL)flag
-{
-    windowIsKey = flag;
-    NSView *documentView = [[mainFrame frameView] documentView];
-    if ([documentView isKindOfClass:[WebHTMLView class]])
-        [(WebHTMLView *)documentView _updateActiveState];
-}
-
-- (void)setMainFrameIsFirstResponder:(BOOL)flag
-{
-    NSView *documentView = [[mainFrame frameView] documentView];
-    
-    NSResponder *firstResponder = flag ? documentView : nil;
-    [[[mainFrame webView] window] makeFirstResponder:firstResponder];
-        
-    if ([documentView isKindOfClass:[WebHTMLView class]])
-        [(WebHTMLView *)documentView _updateActiveState];
-}
-
-- (void)display
-{
-    displayWebView();
-}
-
-- (void)testRepaint
-{
-    testRepaint = YES;
-}
-
-- (void)repaintSweepHorizontally
-{
-    repaintSweepHorizontally = YES;
-}
-
-- (id)invokeUndefinedMethodFromWebScript:(NSString *)name withArguments:(NSArray *)args
-{
-    return nil;
-}
-
-- (void)_addWorkForTarget:(id)target selector:(SEL)selector arg1:(id)arg1 arg2:(id)arg2
-{
-    if (workQueueFrozen)
-        return;
-    NSMethodSignature *sig = [target methodSignatureForSelector:selector];
-    NSInvocation *work = [NSInvocation invocationWithMethodSignature:sig];
-    [work retainArguments];
-    [work setTarget:target];
-    [work setSelector:selector];
-    if (arg1) {
-        [work setArgument:&arg1 atIndex:2];
-        if (arg2)
-            [work setArgument:&arg2 atIndex:3];
-    }
-    [workQueue addObject:work];
-}
-
-- (void)_doLoad:(NSURL *)url target:(NSString *)target
-{
-    WebFrame *targetFrame;
-    if (target && ![target isKindOfClass:[WebUndefined class]])
-        targetFrame = [mainFrame findFrameNamed:target];
-    else
-        targetFrame = mainFrame;
-    [targetFrame loadRequest:[NSURLRequest requestWithURL:url]];
-}
-
-- (void)_doBackOrForwardNavigation:(NSNumber *)index
-{
-    int bfIndex = [index intValue];
-    if (bfIndex == 1)
-        [[mainFrame webView] goForward];
-    if (bfIndex == -1)
-        [[mainFrame webView] goBack];
-    else {        
-        WebBackForwardList *bfList = [[mainFrame webView] backForwardList];
-        [[mainFrame webView] goToBackForwardItem:[bfList itemAtIndex:bfIndex]];
-    }
-}
-
-- (void)queueBackNavigation:(int)howFarBack
-{
-    [self _addWorkForTarget:self selector:@selector(_doBackOrForwardNavigation:) arg1:[NSNumber numberWithInt:-howFarBack] arg2:nil];
-}
-
-- (void)queueForwardNavigation:(int)howFarForward
-{
-    [self _addWorkForTarget:self selector:@selector(_doBackOrForwardNavigation:) arg1:[NSNumber numberWithInt:howFarForward] arg2:nil];
-}
-
-- (void)queueReload
-{
-    [self _addWorkForTarget:[mainFrame webView] selector:@selector(reload:) arg1:self arg2:nil];
-}
-
-- (void)queueScript:(NSString *)script
-{
-    [self _addWorkForTarget:[mainFrame webView] selector:@selector(stringByEvaluatingJavaScriptFromString:) arg1:script arg2:nil];
-}
-
-- (void)queueLoad:(NSString *)URLString target:(NSString *)target
-{
-    NSURL *URL = [NSURL URLWithString:URLString relativeToURL:[[[mainFrame dataSource] response] URL]];
-    [self _addWorkForTarget:self selector:@selector(_doLoad:target:) arg1:URL arg2:target];
-}
-
-- (void)setAcceptsEditing:(BOOL)newAcceptsEditing
-{
-    [(EditingDelegate *)[[mainFrame webView] editingDelegate] setAcceptsEditing:newAcceptsEditing];
-}
-
-- (void)setTabKeyCyclesThroughElements:(BOOL)newTabKeyCyclesThroughElements
-{
-    [[mainFrame webView] setTabKeyCyclesThroughElements:newTabKeyCyclesThroughElements];
-}
-
-- (void)storeWebScriptObject:(WebScriptObject *)webScriptObject
-{
-    if (webScriptObject == storedWebScriptObject)
-        return;
-
-    [storedWebScriptObject release];
-    storedWebScriptObject = [webScriptObject retain];
-}
-
-- (void)accessStoredWebScriptObject
-{
-    JSObjectRef jsObject = [storedWebScriptObject JSObject];
-    ASSERT(!jsObject);
-
-    [storedWebScriptObject callWebScriptMethod:@"" withArguments:nil];
-    [storedWebScriptObject evaluateWebScript:@""];
-    [storedWebScriptObject setValue:[WebUndefined undefined] forKey:@"key"];
-    [storedWebScriptObject valueForKey:@"key"];
-    [storedWebScriptObject removeWebScriptKey:@"key"];
-    [storedWebScriptObject stringRepresentation];
-    [storedWebScriptObject webScriptValueAtIndex:0];
-    [storedWebScriptObject setWebScriptValueAtIndex:0 value:[WebUndefined undefined]];
-    [storedWebScriptObject setException:@"exception"];
-}
-
-- (void)dealloc
-{
-    [storedWebScriptObject release];
-    [super dealloc];
-}
-
-- (NSString*)decodeHostName:(NSString*)name
-{
-    return [name _web_decodeHostName];
-}
-
-- (NSString*)encodeHostName:(NSString*)name
-{
-    return [name _web_encodeHostName];
-}
-
-@end
diff --git a/WebKitTools/DumpRenderTree/LayoutTestControllerMac.mm b/WebKitTools/DumpRenderTree/LayoutTestControllerMac.mm
new file mode 100644 (file)
index 0000000..9e53b3f
--- /dev/null
@@ -0,0 +1,308 @@
+/*
+ * Copyright (C) 2007 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1.  Redistributions of source code must retain the above copyright
+ *     notice, this list of conditions and the following disclaimer. 
+ * 2.  Redistributions in binary form must reproduce the above copyright
+ *     notice, this list of conditions and the following disclaimer in the
+ *     documentation and/or other materials provided with the distribution. 
+ * 3.  Neither the name of Apple Computer, Inc. ("Apple") nor the names of
+ *     its contributors may be used to endorse or promote products derived
+ *     from this software without specific prior written permission. 
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#import "LayoutTestController.h"
+
+#import "DumpRenderTree.h"
+#import "EditingDelegate.h"
+#import "WorkQueue.h"
+#import "WorkQueueItem.h"
+#import <JavaScriptCore/JSRetainPtr.h>
+#import <JavaScriptCore/JSStringRef.h>
+#import <JavaScriptCore/JSStringRefCF.h>
+#import <JavaScriptCore/RetainPtr.h>
+#import <WebKit/WebBackForwardList.h>
+#import <WebKit/WebFrame.h>
+#import <WebKit/WebHTMLViewPrivate.h>
+#import <WebKit/WebHistory.h>
+#import <WebKit/WebNSURLExtras.h>
+#import <WebKit/WebPreferences.h>
+#import <WebKit/WebView.h>
+#import <WebKit/WebViewPrivate.h>
+
+#import <Foundation/Foundation.h>
+
+void LayoutTestController::dumpAsText()
+{
+    ::dumpAsText = true;
+}
+
+void LayoutTestController::dumpBackForwardList()
+{
+    ::dumpBackForwardList = true;
+}
+
+void LayoutTestController::dumpChildFramesAsText()
+{
+    ::dumpChildFramesAsText = true;
+}
+
+void LayoutTestController::dumpChildFrameScrollPositions()
+{
+    ::dumpChildFrameScrollPositions = true;
+}
+
+void LayoutTestController::dumpDOMAsWebArchive()
+{
+    ::dumpDOMAsWebArchive = true;
+}
+
+void LayoutTestController::dumpEditingCallbacks()
+{
+    ::shouldDumpEditingCallbacks = true;
+}
+
+void LayoutTestController::dumpFrameLoadCallbacks()
+{
+    ::shouldDumpFrameLoadCallbacks = true;
+}
+
+void LayoutTestController::dumpResourceLoadCallbacks()
+{
+    ::shouldDumpResourceLoadCallbacks = true;
+}
+
+void LayoutTestController::dumpSelectionRect()
+{
+    ::dumpSelectionRect = true;
+}
+
+void LayoutTestController::dumpSourceAsWebArchive()
+{
+    ::dumpSourceAsWebArchive = true;
+}
+
+void LayoutTestController::dumpTitleChanges()
+{
+    ::dumpTitleChanges = true;
+}
+
+void LayoutTestController::repaintSweepHorizontally()
+{
+    ::repaintSweepHorizontally = true;
+}
+
+void LayoutTestController::setCallCloseOnWebViews()
+{
+    ::closeWebViews = true;
+}
+
+void LayoutTestController::setCanOpenWindows()
+{
+    ::canOpenWindows = true;
+}
+
+void LayoutTestController::setCloseRemainingWindowsWhenComplete()
+{
+    ::closeRemainingWindowsWhenComplete = true;
+}
+
+void LayoutTestController::testRepaint()
+{
+    ::testRepaint = true;
+}
+
+void LayoutTestController::addFileToPasteboardOnDrag()
+{
+    ::addFileToPasteboardOnDrag = true;
+}
+
+void LayoutTestController::addDisallowedURL(JSStringRef url)
+{
+    RetainPtr<CFStringRef> urlCF(AdoptCF, JSStringCopyCFString(kCFAllocatorDefault, url));
+
+    if (!disallowedURLs)
+        disallowedURLs = [[NSMutableSet alloc] init];
+
+    // Canonicalize the URL
+    NSURLRequest* request = [NSURLRequest requestWithURL:[NSURL URLWithString:(NSString *)urlCF.get()]];
+    request = [NSURLProtocol canonicalRequestForRequest:request];
+
+    [disallowedURLs addObject:[request URL]];
+}
+
+void LayoutTestController::clearBackForwardList()
+{
+    WebBackForwardList *backForwardList = [[mainFrame webView] backForwardList];
+    WebHistoryItem *item = [[backForwardList currentItem] retain];
+
+    // We clear the history by setting the back/forward list's capacity to 0
+    // then restoring it back and adding back the current item.
+    int capacity = [backForwardList capacity];
+    [backForwardList setCapacity:0];
+    [backForwardList setCapacity:capacity];
+    [backForwardList addItem:item];
+    [backForwardList goToItem:item];
+    [item release];
+}
+
+JSStringRef LayoutTestController::decodeHostName(JSStringRef name)
+{
+    RetainPtr<CFStringRef> nameCF(AdoptCF, JSStringCopyCFString(kCFAllocatorDefault, name));
+    NSString *nameNS = (NSString *)nameCF.get();
+    return JSStringCreateWithCFString((CFStringRef)[nameNS _web_decodeHostName]);
+}
+
+JSStringRef LayoutTestController::encodeHostName(JSStringRef name)
+{
+    RetainPtr<CFStringRef> nameCF(AdoptCF, JSStringCopyCFString(kCFAllocatorDefault, name));
+    NSString *nameNS = (NSString *)nameCF.get();
+    return JSStringCreateWithCFString((CFStringRef)[nameNS _web_encodeHostName]);
+}
+
+void LayoutTestController::display()
+{
+    displayWebView();
+}
+
+void LayoutTestController::keepWebHistory()
+{
+    if (![WebHistory optionalSharedHistory]) {
+        WebHistory *history = [[WebHistory alloc] init];
+        [WebHistory setOptionalSharedHistory:history];
+        [history release];
+    }
+}
+
+void LayoutTestController::notifyDone()
+{
+    if (waitToDump && !topLoadingFrame && !WorkQueue::shared()->count())
+        dump();
+    waitToDump = false;
+}
+
+void LayoutTestController::queueBackNavigation(int howFarBack)
+{
+    WorkQueue::shared()->queue(new BackItem(howFarBack));
+}
+
+void LayoutTestController::queueForwardNavigation(int howFarForward)
+{
+    WorkQueue::shared()->queue(new ForwardItem(howFarForward));
+}
+
+void LayoutTestController::queueLoad(JSStringRef url, JSStringRef target)
+{
+    RetainPtr<CFStringRef> urlCF(AdoptCF, JSStringCopyCFString(kCFAllocatorDefault, url));
+    NSString *urlNS = (NSString *)urlCF.get();
+
+    NSURL *nsurl = [NSURL URLWithString:urlNS relativeToURL:[[[mainFrame dataSource] response] URL]];
+    NSString* nsurlString = [nsurl absoluteString];
+
+    WorkQueue::shared()->queue(new LoadItem(JSStringCreateWithUTF8CString([nsurlString UTF8String]), target));
+}
+
+void LayoutTestController::queueReload()
+{
+    WorkQueue::shared()->queue(new ReloadItem);
+}
+
+void LayoutTestController::queueScript(JSStringRef script)
+{
+    WorkQueue::shared()->queue(new ScriptItem(script));
+}
+
+void LayoutTestController::setAcceptsEditing(bool newAcceptsEditing)
+{
+    [(EditingDelegate *)[[mainFrame webView] editingDelegate] setAcceptsEditing:newAcceptsEditing];
+}
+
+void LayoutTestController::setCustomPolicyDelegate(bool setDelegate)
+{
+    if (setDelegate)
+        [[mainFrame webView] setPolicyDelegate:policyDelegate];
+    else
+        [[mainFrame webView] setPolicyDelegate:nil];
+}
+
+void LayoutTestController::setMainFrameIsFirstResponder(bool flag)
+{
+    NSView *documentView = [[mainFrame frameView] documentView];
+    
+    NSResponder *firstResponder = flag ? documentView : nil;
+    [[[mainFrame webView] window] makeFirstResponder:firstResponder];
+        
+    if ([documentView isKindOfClass:[WebHTMLView class]])
+        [(WebHTMLView *)documentView _updateActiveState];
+}
+
+void LayoutTestController::setTabKeyCyclesThroughElements(bool cycles)
+{
+    [[mainFrame webView] setTabKeyCyclesThroughElements:cycles];
+}
+
+void LayoutTestController::setUseDashboardCompatibilityMode(bool flag)
+{
+    [[mainFrame webView] _setDashboardBehavior:WebDashboardBehaviorUseBackwardCompatibilityMode to:flag];
+}
+
+void LayoutTestController::setUserStyleSheetEnabled(bool flag)
+{
+    [[WebPreferences standardPreferences] setUserStyleSheetEnabled:flag];
+}
+
+void LayoutTestController::setUserStyleSheetLocation(JSStringRef path)
+{
+    RetainPtr<CFStringRef> pathCF(AdoptCF, JSStringCopyCFString(kCFAllocatorDefault, path));
+    NSURL *url = [NSURL URLWithString:(NSString *)pathCF.get()];
+    [[WebPreferences standardPreferences] setUserStyleSheetLocation:url];
+}
+
+void LayoutTestController::setWindowIsKey(bool flag)
+{
+    windowIsKey = flag;
+    NSView *documentView = [[mainFrame frameView] documentView];
+    if ([documentView isKindOfClass:[WebHTMLView class]])
+        [(WebHTMLView *)documentView _updateActiveState];
+}
+
+@interface WaitToDumpWatchdog : NSObject
++ (void)waitUntilDoneWatchdogFired;
+@end
+
+@implementation WaitToDumpWatchdog
++ (void)waitUntilDoneWatchdogFired
+{
+    const char* message = "FAIL: Timed out waiting for notifyDone to be called\n";
+    fprintf(stderr, message);
+    fprintf(stdout, message);
+    dump();
+}
+@end
+
+void LayoutTestController::waitUntilDone()
+{
+    waitToDump = true;
+    if (!waitToDumpWatchdog)
+        waitToDumpWatchdog = [[NSTimer scheduledTimerWithTimeInterval:waitToDumpWatchdogInterval target:[WaitToDumpWatchdog class] selector:@selector(waitUntilDoneWatchdogFired) userInfo:nil repeats:NO] retain];
+}
+
+int LayoutTestController::windowCount()
+{
+    return CFArrayGetCount(allWindowsRef);
+}
index 1287551..d1d001c 100644 (file)
 
 #import <Foundation/Foundation.h>
 
+@class WebScriptObject;
+
+// This controller should be used to test Objective-C language features and the WebScriptObject.
 @interface ObjCController : NSObject
+{
+    WebScriptObject *storedWebScriptObject;
+}
 @end
index d9662de..c738a2b 100644 (file)
@@ -28,8 +28,9 @@
 
 #import "ObjCController.h"
 
-#import <WebKit/WebView.h>
+#import <JavaScriptCore/Assertions.h>
 #import <WebKit/WebScriptObject.h>
+#import <WebKit/WebView.h>
 
 @implementation ObjCController
 
             || aSelector == @selector(identityIsEqual::)
             || aSelector == @selector(longLongRoundTrip:)
             || aSelector == @selector(unsignedLongLongRoundTrip:)
-            || aSelector == @selector(testWrapperRoundTripping:))
+            || aSelector == @selector(testWrapperRoundTripping:)
+            || aSelector == @selector(accessStoredWebScriptObject)
+            || aSelector == @selector(storeWebScriptObject:)
+        )
         return NO;
     return YES;
 }
@@ -60,6 +64,8 @@
         return @"unsignedLongLongRoundTrip";
     if (aSelector == @selector(testWrapperRoundTripping:))
         return @"testWrapperRoundTripping";
+    if (aSelector == @selector(storeWebScriptObject:))
+        return @"storeWebScriptObject";
 
     return nil;
 }
     return true;
 }
 
+- (void)accessStoredWebScriptObject
+{
+    JSObjectRef jsObject = [storedWebScriptObject JSObject];
+    ASSERT(!jsObject);
+
+    [storedWebScriptObject callWebScriptMethod:@"" withArguments:nil];
+    [storedWebScriptObject evaluateWebScript:@""];
+    [storedWebScriptObject setValue:[WebUndefined undefined] forKey:@"key"];
+    [storedWebScriptObject valueForKey:@"key"];
+    [storedWebScriptObject removeWebScriptKey:@"key"];
+    [storedWebScriptObject stringRepresentation];
+    [storedWebScriptObject webScriptValueAtIndex:0];
+    [storedWebScriptObject setWebScriptValueAtIndex:0 value:[WebUndefined undefined]];
+    [storedWebScriptObject setException:@"exception"];
+}
+
+- (void)storeWebScriptObject:(WebScriptObject *)webScriptObject
+{
+    if (webScriptObject == storedWebScriptObject)
+        return;
+
+    [storedWebScriptObject release];
+    storedWebScriptObject = [webScriptObject retain];
+}
+
+- (void)dealloc
+{
+    [storedWebScriptObject release];
+    [super dealloc];
+}
+
+- (id)invokeUndefinedMethodFromWebScript:(NSString *)name withArguments:(NSArray *)args
+{
+    // FIXME: Perhaps we should log that this has been called.
+    return nil;
+}
+
 @end
diff --git a/WebKitTools/DumpRenderTree/WorkQueue.cpp b/WebKitTools/DumpRenderTree/WorkQueue.cpp
new file mode 100644 (file)
index 0000000..a5adb36
--- /dev/null
@@ -0,0 +1,88 @@
+/*
+ * Copyright (C) 2007 Apple Inc.  All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1.  Redistributions of source code must retain the above copyright
+ *     notice, this list of conditions and the following disclaimer. 
+ * 2.  Redistributions in binary form must reproduce the above copyright
+ *     notice, this list of conditions and the following disclaimer in the
+ *     documentation and/or other materials provided with the distribution. 
+ * 3.  Neither the name of Apple Computer, Inc. ("Apple") nor the names of
+ *     its contributors may be used to endorse or promote products derived
+ *     from this software without specific prior written permission. 
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "DumpRenderTree.h"
+#include "WorkQueue.h"
+
+#include "WorkQueueItem.h"
+
+#include <JavaScriptCore/Assertions.h>
+
+static const unsigned queueLength = 1024;
+
+static WorkQueueItem* theQueue[queueLength];
+static unsigned startOfQueue;
+static unsigned endOfQueue;
+
+WorkQueue* WorkQueue::shared()
+{
+    static WorkQueue* sharedInstance = new WorkQueue;
+    return sharedInstance;
+}
+
+WorkQueue::WorkQueue()
+    : m_frozen(false)
+{
+}
+
+void WorkQueue::queue(WorkQueueItem* item)
+{
+    ASSERT(endOfQueue < queueLength);
+    ASSERT(endOfQueue >= startOfQueue);
+
+    if (m_frozen)
+        return;
+
+    theQueue[endOfQueue++] = item;
+}
+
+WorkQueueItem* WorkQueue::dequeue()
+{
+    ASSERT(endOfQueue >= startOfQueue);
+
+    if (startOfQueue == endOfQueue)
+        return 0;
+
+    return theQueue[startOfQueue++];
+}
+
+unsigned WorkQueue::count()
+{
+    return endOfQueue - startOfQueue;
+}
+
+void WorkQueue::clear()
+{
+    for (unsigned i = startOfQueue; i < endOfQueue; ++i) {
+        delete theQueue[i];
+        theQueue[i] = 0;
+    }
+
+    startOfQueue = 0;
+    endOfQueue = 0;
+}
diff --git a/WebKitTools/DumpRenderTree/WorkQueue.h b/WebKitTools/DumpRenderTree/WorkQueue.h
new file mode 100644 (file)
index 0000000..c2850c5
--- /dev/null
@@ -0,0 +1,51 @@
+/*
+ * Copyright (C) 2007 Apple Inc.  All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1.  Redistributions of source code must retain the above copyright
+ *     notice, this list of conditions and the following disclaimer. 
+ * 2.  Redistributions in binary form must reproduce the above copyright
+ *     notice, this list of conditions and the following disclaimer in the
+ *     documentation and/or other materials provided with the distribution. 
+ * 3.  Neither the name of Apple Computer, Inc. ("Apple") nor the names of
+ *     its contributors may be used to endorse or promote products derived
+ *     from this software without specific prior written permission. 
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef WorkQueue_h
+#define WorkQueue_h
+
+class WorkQueueItem;
+
+class WorkQueue {
+public:
+    static WorkQueue* shared();
+
+    void queue(WorkQueueItem*);
+    WorkQueueItem* dequeue();
+    void clear();
+    unsigned count();
+
+    void setFrozen(bool b) { m_frozen = b; }
+
+private:
+    WorkQueue();
+
+    bool m_frozen;
+};
+
+#endif // !defined(WorkQueue_h)
diff --git a/WebKitTools/DumpRenderTree/WorkQueueItem.h b/WebKitTools/DumpRenderTree/WorkQueueItem.h
new file mode 100644 (file)
index 0000000..fd15329
--- /dev/null
@@ -0,0 +1,108 @@
+/*
+ * Copyright (C) 2007 Apple Inc.  All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1.  Redistributions of source code must retain the above copyright
+ *     notice, this list of conditions and the following disclaimer. 
+ * 2.  Redistributions in binary form must reproduce the above copyright
+ *     notice, this list of conditions and the following disclaimer in the
+ *     documentation and/or other materials provided with the distribution. 
+ * 3.  Neither the name of Apple Computer, Inc. ("Apple") nor the names of
+ *     its contributors may be used to endorse or promote products derived
+ *     from this software without specific prior written permission. 
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef WorkQueueItem_h
+#define WorkQueueItem_h
+
+#include <JavaScriptCore/JSRetainPtr.h>
+#include <JavaScriptCore/JSBase.h>
+
+class WorkQueueItem {
+public:
+    virtual ~WorkQueueItem() { }
+    virtual void invoke() const = 0;
+};
+
+class LoadItem : public WorkQueueItem {
+public:
+    LoadItem(const JSStringRef url, const JSStringRef target)
+        : m_url(url)
+        , m_target(target)
+    {
+    }
+
+    const JSStringRef url() const { return m_url.get(); }
+    const JSStringRef target() const { return m_target.get(); }
+
+    virtual void invoke() const;
+
+private:
+    JSRetainPtr<JSStringRef> m_url;
+    JSRetainPtr<JSStringRef> m_target;
+};
+
+class ReloadItem : public WorkQueueItem {
+public:
+    virtual void invoke() const;
+};
+
+class ScriptItem : public WorkQueueItem {
+public:
+    ScriptItem(const JSStringRef script)
+        : m_script(script)
+    {
+    }
+
+    const JSStringRef script() const { return m_script.get(); }
+
+    virtual void invoke() const;
+
+private:
+    JSRetainPtr<JSStringRef> m_script;
+};
+
+class BackForwardItem : public WorkQueueItem {
+public:
+    virtual void invoke() const;
+
+protected:
+    BackForwardItem(int howFar)
+        : m_howFar(howFar)
+    {
+    }
+
+    int m_howFar;
+};
+
+class BackItem : public BackForwardItem {
+public:
+    BackItem(unsigned howFar)
+        : BackForwardItem(-howFar)
+    {
+    }
+};
+
+class ForwardItem : public BackForwardItem {
+public:
+    ForwardItem(unsigned howFar)
+        : BackForwardItem(howFar)
+    {
+    }
+};
+
+#endif // !defined(WorkQueueItem_h)
diff --git a/WebKitTools/DumpRenderTree/WorkQueueItemMac.mm b/WebKitTools/DumpRenderTree/WorkQueueItemMac.mm
new file mode 100644 (file)
index 0000000..7216056
--- /dev/null
@@ -0,0 +1,77 @@
+/*
+ * Copyright (C) 2007 Apple Inc.  All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1.  Redistributions of source code must retain the above copyright
+ *     notice, this list of conditions and the following disclaimer. 
+ * 2.  Redistributions in binary form must reproduce the above copyright
+ *     notice, this list of conditions and the following disclaimer in the
+ *     documentation and/or other materials provided with the distribution. 
+ * 3.  Neither the name of Apple Computer, Inc. ("Apple") nor the names of
+ *     its contributors may be used to endorse or promote products derived
+ *     from this software without specific prior written permission. 
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#import "WorkQueueItem.h"
+
+#import "DumpRenderTree.h"
+#import <JavaScriptCore/JSStringRef.h>
+#import <JavaScriptCore/JSStringRefCF.h>
+#import <JavaScriptCore/RetainPtr.h>
+#import <WebKit/WebBackForwardList.h>
+#import <WebKit/WebFrame.h>
+#import <WebKit/WebScriptObject.h>
+#import <WebKit/WebView.h>
+
+void LoadItem::invoke() const
+{
+    RetainPtr<CFStringRef> urlCF(AdoptCF, JSStringCopyCFString(kCFAllocatorDefault, m_url.get()));
+    NSString *urlNS = (NSString *)urlCF.get();
+    RetainPtr<CFStringRef> targetCF(AdoptCF, JSStringCopyCFString(kCFAllocatorDefault, m_target.get()));
+    NSString *targetNS = (NSString *)targetCF.get();
+
+    WebFrame *targetFrame;
+    if (targetNS && [targetNS length])
+        targetFrame = [mainFrame findFrameNamed:targetNS];
+    else
+        targetFrame = mainFrame;
+    [targetFrame loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:urlNS]]];
+}
+
+void ReloadItem::invoke() const
+{
+    [[mainFrame webView] reload:nil];
+}
+
+void ScriptItem::invoke() const
+{
+    RetainPtr<CFStringRef> scriptCF(AdoptCF, JSStringCopyCFString(kCFAllocatorDefault, m_script.get()));
+    NSString *scriptNS = (NSString *)scriptCF.get();
+    [[mainFrame webView] stringByEvaluatingJavaScriptFromString:scriptNS];
+}
+
+void BackForwardItem::invoke() const
+{
+    if (m_howFar == 1)
+        [[mainFrame webView] goForward];
+    else if (m_howFar == -1)
+        [[mainFrame webView] goBack];
+    else {
+        WebBackForwardList *bfList = [[mainFrame webView] backForwardList];
+        [[mainFrame webView] goToBackForwardItem:[bfList itemAtIndex:m_howFar]];
+    }
+}