diff options
author | Kristian Monsen <kristianm@google.com> | 2010-09-08 12:18:00 +0100 |
---|---|---|
committer | Kristian Monsen <kristianm@google.com> | 2010-09-11 12:08:58 +0100 |
commit | 5ddde30071f639962dd557c453f2ad01f8f0fd00 (patch) | |
tree | 775803c4ab35af50aa5f5472cd1fb95fe9d5152d /WebKitTools/WebKitTestRunner/InjectedBundle | |
parent | 3e63d9b33b753ca86d0765d1b3d711114ba9e34f (diff) | |
download | external_webkit-5ddde30071f639962dd557c453f2ad01f8f0fd00.zip external_webkit-5ddde30071f639962dd557c453f2ad01f8f0fd00.tar.gz external_webkit-5ddde30071f639962dd557c453f2ad01f8f0fd00.tar.bz2 |
Merge WebKit at r66666 : Initial merge by git.
Change-Id: I57dedeb49859adc9c539e760f0e749768c66626f
Diffstat (limited to 'WebKitTools/WebKitTestRunner/InjectedBundle')
5 files changed, 38 insertions, 1 deletions
diff --git a/WebKitTools/WebKitTestRunner/InjectedBundle/Bindings/LayoutTestController.idl b/WebKitTools/WebKitTestRunner/InjectedBundle/Bindings/LayoutTestController.idl index 7993d78..f3c5e88 100644 --- a/WebKitTools/WebKitTestRunner/InjectedBundle/Bindings/LayoutTestController.idl +++ b/WebKitTools/WebKitTestRunner/InjectedBundle/Bindings/LayoutTestController.idl @@ -44,6 +44,7 @@ module WTR { void setAcceptsEditing(in boolean value); void setCanOpenWindows(in boolean value); void setCloseRemainingWindowsWhenComplete(in boolean value); + void setXSSAuditorEnabled(in boolean value); unsigned long windowCount(); // Special DOM functions. @@ -61,6 +62,10 @@ module WTR { // Animation testing. int numberOfActiveAnimations(); boolean pauseAnimationAtTimeOnElementWithId(in DOMString animationName, in double time, in DOMString elementId); + + // UserContent testing. + void addUserScript(in DOMString source, in boolean runAtStart, in boolean allFrames); + void addUserStyleSheet(in DOMString source, in boolean allFrames); }; } diff --git a/WebKitTools/WebKitTestRunner/InjectedBundle/InjectedBundle.cpp b/WebKitTools/WebKitTestRunner/InjectedBundle/InjectedBundle.cpp index b2aa836..ecc302f 100644 --- a/WebKitTools/WebKitTestRunner/InjectedBundle/InjectedBundle.cpp +++ b/WebKitTools/WebKitTestRunner/InjectedBundle/InjectedBundle.cpp @@ -133,6 +133,8 @@ void InjectedBundle::beginTesting() WKBundleSetShouldTrackVisitedLinks(m_bundle, false); WKBundleRemoveAllVisitedLinks(m_bundle); + WKBundleRemoveAllUserContent(m_bundle); + m_mainPage->reset(); } diff --git a/WebKitTools/WebKitTestRunner/InjectedBundle/InjectedBundlePage.cpp b/WebKitTools/WebKitTestRunner/InjectedBundle/InjectedBundlePage.cpp index 424f7ab..c7f9a84 100644 --- a/WebKitTools/WebKitTestRunner/InjectedBundle/InjectedBundlePage.cpp +++ b/WebKitTools/WebKitTestRunner/InjectedBundle/InjectedBundlePage.cpp @@ -100,6 +100,7 @@ InjectedBundlePage::InjectedBundlePage(WKBundlePageRef page) didReceiveServerRedirectForProvisionalLoadForFrame, didFailProvisionalLoadWithErrorForFrame, didCommitLoadForFrame, + didFinishDocumentLoadForFrame, didFinishLoadForFrame, didFailLoadWithErrorForFrame, didReceiveTitleForFrame, @@ -107,7 +108,6 @@ InjectedBundlePage::InjectedBundlePage(WKBundlePageRef page) didCancelClientRedirectForFrame, willPerformClientRedirectForFrame, didChangeLocationWithinPageForFrame, - didFinishDocumentLoadForFrame, didHandleOnloadEventsForFrame, didDisplayInsecureContentForFrame, didRunInsecureContentForFrame diff --git a/WebKitTools/WebKitTestRunner/InjectedBundle/LayoutTestController.cpp b/WebKitTools/WebKitTestRunner/InjectedBundle/LayoutTestController.cpp index f2393f1..d54bb1d 100644 --- a/WebKitTools/WebKitTestRunner/InjectedBundle/LayoutTestController.cpp +++ b/WebKitTools/WebKitTestRunner/InjectedBundle/LayoutTestController.cpp @@ -32,6 +32,7 @@ #include <WebKit2/WKBundleFrame.h> #include <WebKit2/WKBundleFramePrivate.h> #include <WebKit2/WKBundlePagePrivate.h> +#include <WebKit2/WKBundleScriptWorld.h> #include <WebKit2/WKBundlePrivate.h> #include <WebKit2/WKRetainPtr.h> #include <WebKit2/WebKit2.h> @@ -163,6 +164,25 @@ bool LayoutTestController::pauseAnimationAtTimeOnElementWithId(JSStringRef anima return WKBundleFramePauseAnimationOnElementWithId(mainFrame, toWK(animationName).get(), toWK(elementId).get(), time); } +void LayoutTestController::addUserScript(JSStringRef source, bool runAtStart, bool allFrames) +{ + WKRetainPtr<WKStringRef> sourceWK = toWK(source); + WKRetainPtr<WKBundleScriptWorldRef> scriptWorld(AdoptWK, WKBundleScriptWorldCreateWorld()); + + WKBundleAddUserScript(InjectedBundle::shared().bundle(), scriptWorld.get(), sourceWK.get(), 0, 0, 0, + (runAtStart ? kWKInjectAtDocumentStart : kWKInjectAtDocumentEnd), + (allFrames ? kWKInjectInAllFrames : kWKInjectInTopFrameOnly)); +} + +void LayoutTestController::addUserStyleSheet(JSStringRef source, bool allFrames) +{ + WKRetainPtr<WKStringRef> sourceWK = toWK(source); + WKRetainPtr<WKBundleScriptWorldRef> scriptWorld(AdoptWK, WKBundleScriptWorldCreateWorld()); + + WKBundleAddUserStyleSheet(InjectedBundle::shared().bundle(), scriptWorld.get(), sourceWK.get(), 0, 0, 0, + (allFrames ? kWKInjectInAllFrames : kWKInjectInTopFrameOnly)); +} + void LayoutTestController::keepWebHistory() { WKBundleSetShouldTrackVisitedLinks(InjectedBundle::shared().bundle(), true); @@ -219,6 +239,11 @@ void LayoutTestController::setCanOpenWindows(bool) // For now, just ignore this setting, and if we find later it's needed we can add it. } +void LayoutTestController::setXSSAuditorEnabled(bool enabled) +{ + WKBundleOverrideXSSAuditorEnabledForTestRunner(InjectedBundle::shared().bundle(), true); +} + unsigned LayoutTestController::windowCount() { return InjectedBundle::shared().pageCount(); diff --git a/WebKitTools/WebKitTestRunner/InjectedBundle/LayoutTestController.h b/WebKitTools/WebKitTestRunner/InjectedBundle/LayoutTestController.h index 7c3125c..2c112a7 100644 --- a/WebKitTools/WebKitTestRunner/InjectedBundle/LayoutTestController.h +++ b/WebKitTools/WebKitTestRunner/InjectedBundle/LayoutTestController.h @@ -62,6 +62,7 @@ public: void setAcceptsEditing(bool value) { m_shouldAllowEditing = value; } void setCanOpenWindows(bool); void setCloseRemainingWindowsWhenComplete(bool value) { m_shouldCloseExtraWindows = value; } + void setXSSAuditorEnabled(bool); unsigned windowCount(); // Special DOM functions. @@ -80,6 +81,10 @@ public: unsigned numberOfActiveAnimations() const; bool pauseAnimationAtTimeOnElementWithId(JSStringRef animationName, double time, JSStringRef elementId); + // UserContent testing. + void addUserScript(JSStringRef source, bool runAtStart, bool allFrames); + void addUserStyleSheet(JSStringRef source, bool allFrames); + enum WhatToDump { RenderTree, MainFrameText, AllFramesText }; WhatToDump whatToDump() const { return m_whatToDump; } |