Web Inspector: model tests should use a special Test.html inspector page
authorbburg@apple.com <bburg@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 27 Feb 2014 22:08:10 +0000 (22:08 +0000)
committerbburg@apple.com <bburg@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 27 Feb 2014 22:08:10 +0000 (22:08 +0000)
commiteb2755971173570c7c1ffedeee68e94c2caa12d5
tree1a1caaa7c1151eac7d9763a9862d9ea4ccc32e3b
parentd39ef4cd3ded8d254665d6fe57ad81742ea84c4f
Web Inspector: model tests should use a special Test.html inspector page
https://bugs.webkit.org/show_bug.cgi?id=129190

Reviewed by Timothy Hatcher.

Source/WebCore:

Convert InspectorController::isUnderTest() into a flag, and expose an
Internals method so it can be set by the test before opening the inspector.

Test: inspector/test-harness-trivially-works.html

* inspector/InspectorController.cpp:
(WebCore::InspectorController::evaluateForTestInFrontend):
* inspector/InspectorController.h:
* testing/Internals.cpp:
(WebCore::Internals::setInspectorIsUnderTest): Added.
* testing/Internals.h:
* testing/Internals.idl:

Source/WebInspectorUI:

* UserInterface/Base/Test.js: Added.
(WebInspector.loaded):
(WebInspector.contentLoaded):
(WebInspector.updateDockedState):
(InspectorTest.log):
(InspectorTest.assert):
(InspectorTest.debugLog):
(InspectorTest.completeTest):
(InspectorTest.evaluateInPage):
(InspectorTest.addResult):
(InspectorTest.clearResults):
(InspectorTest.pageLoaded):
(InspectorTest.reportUncaughtException):
(.console.logType):
* UserInterface/Protocol/InspectorBackend.js:
(InspectorBackendClass):
(InspectorBackendClass.prototype.dispatch):
(InspectorBackendClass.prototype.runAfterPendingDispatches):
(InspectorBackendClass.prototype._flushPendingScripts):
* UserInterface/Protocol/InspectorObserver.js:
(WebInspector.InspectorObserver.prototype.evaluateForTestInFrontend):
* UserInterface/Test.html: Added.

Source/WebKit/mac:

Support creating a separate test inspector page, based on the value of
InspectorController::isUnderTest(). Modify the navigation policy to check
the URL against both normal and test inspector pages.

* WebCoreSupport/WebInspectorClient.mm:
(WebInspectorClient::openInspectorFrontend):
(-[WebInspectorWindowController init]):
(-[WebInspectorWindowController initWithInspectedWebView:isUnderTest:]):
Move the initial navigation of the inspector page to this method, and change
the URL based on the value of InspectorController::isUnderTest().

(-[WebInspectorWindowController inspectorTestPagePath]): Added.
(-[WebInspectorWindowController webView:decidePolicyForNavigationAction:request:frame:decisionListener:]):

Source/WebKit2:

Support creating a separate test inspector page, based on the value of
InspectorController::isUnderTest(). Add this as a separate API call for
WebInspectorProxy. Modify the navigation policy to check the URL against
both normal and test inspector pages.

* UIProcess/WebInspectorProxy.cpp:
(WebKit::isMainOrTestInspectorPage):
(WebKit::decidePolicyForNavigationAction):
(WebKit::WebInspectorProxy::createInspectorPageForTest):
* UIProcess/WebInspectorProxy.h:
* UIProcess/WebInspectorProxy.messages.in:
* UIProcess/efl/WebInspectorProxyEfl.cpp:
(WebKit::WebInspectorProxy::inspectorTestPageURL):
* UIProcess/gtk/WebInspectorProxyGtk.cpp:
(WebKit::WebInspectorProxy::inspectorTestPageURL):
* UIProcess/ios/WebInspectorProxyIOS.mm:
(WebKit::WebInspectorProxy::inspectorTestPageURL):
* UIProcess/mac/WebInspectorProxyMac.mm:
(WebKit::WebInspectorProxy::inspectorTestPageURL):
* WebProcess/WebCoreSupport/WebInspectorClient.cpp:
(WebKit::WebInspectorClient::openInspectorFrontend):
* WebProcess/WebPage/WebInspector.cpp: Some drive-by nullptr refactorings.
(WebKit::WebInspector::WebInspector):
(WebKit::WebInspector::createInspectorPage):
(WebKit::WebInspector::createInspectorPageForTest):
(WebKit::WebInspector::destroyInspectorPage):
* WebProcess/WebPage/WebInspector.h:

Tools:

Remove code that immediately opens the Web Inspector based on the file path of the test.
Instead, the test page should request that the inspector open inside its `test()` method.

This change is necessary because otherwise, the inspector would be opened too early for
InspectorController::isUnderTest to get set in time, so the normal Web Inspector page
will get loaded instead of the minimal test page.

* DumpRenderTree/efl/DumpRenderTree.cpp:
(createTestRunner):
* DumpRenderTree/gtk/DumpRenderTree.cpp:
(runTest):
* DumpRenderTree/mac/DumpRenderTree.mm:
(runTest):
* DumpRenderTree/win/DumpRenderTree.cpp:
(runTest):

LayoutTests:

Add a stripped-down version of the inspector test script that's used by
all inspector model tests. Clean up the namespaces so things accessible
from only the test page are part of the `InspectorTestProxy` object.

Add a minimal test that exercises the initialization and communication code
paths on the test page and the inspector page.

* http/tests/inspector-protocol/resources/InspectorTest.js: Add a FIXME.
* inspector/inspector-test.js: Added.
(InspectorTestProxy.register):
(runTest.initializeFrontend):
(runTest.runTestInFrontend):
(runTest):
(InspectorTestProxy.completeTest):
(InspectorTestProxy.debugLog):
(InspectorTestProxy.addResult):
(InspectorTestProxy.clearResults):
(InspectorTestProxy.reportUncaughtException):
* inspector/test-harness-trivially-works-expected.txt: Added.
* inspector/test-harness-trivially-works.html: Added.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@164830 268f45cc-cd09-0410-ab3c-d52691b4dbfc
34 files changed:
LayoutTests/ChangeLog
LayoutTests/http/tests/inspector-protocol/resources/InspectorTest.js
LayoutTests/inspector/inspector-test.js [new file with mode: 0644]
LayoutTests/inspector/test-harness-trivially-works-expected.txt [new file with mode: 0644]
LayoutTests/inspector/test-harness-trivially-works.html [new file with mode: 0644]
Source/WebCore/ChangeLog
Source/WebCore/inspector/InspectorController.cpp
Source/WebCore/inspector/InspectorController.h
Source/WebCore/testing/Internals.cpp
Source/WebCore/testing/Internals.h
Source/WebCore/testing/Internals.idl
Source/WebInspectorUI/ChangeLog
Source/WebInspectorUI/UserInterface/Base/Test.js [new file with mode: 0644]
Source/WebInspectorUI/UserInterface/Protocol/InspectorBackend.js
Source/WebInspectorUI/UserInterface/Protocol/InspectorObserver.js
Source/WebInspectorUI/UserInterface/Test.html [new file with mode: 0644]
Source/WebKit/mac/ChangeLog
Source/WebKit/mac/WebCoreSupport/WebInspectorClient.mm
Source/WebKit2/ChangeLog
Source/WebKit2/UIProcess/WebInspectorProxy.cpp
Source/WebKit2/UIProcess/WebInspectorProxy.h
Source/WebKit2/UIProcess/WebInspectorProxy.messages.in
Source/WebKit2/UIProcess/efl/WebInspectorProxyEfl.cpp
Source/WebKit2/UIProcess/gtk/WebInspectorProxyGtk.cpp
Source/WebKit2/UIProcess/ios/WebInspectorProxyIOS.mm
Source/WebKit2/UIProcess/mac/WebInspectorProxyMac.mm
Source/WebKit2/WebProcess/WebCoreSupport/WebInspectorClient.cpp
Source/WebKit2/WebProcess/WebPage/WebInspector.cpp
Source/WebKit2/WebProcess/WebPage/WebInspector.h
Tools/ChangeLog
Tools/DumpRenderTree/efl/DumpRenderTree.cpp
Tools/DumpRenderTree/gtk/DumpRenderTree.cpp
Tools/DumpRenderTree/mac/DumpRenderTree.mm
Tools/DumpRenderTree/win/DumpRenderTree.cpp