summaryrefslogtreecommitdiff
path: root/Source/WebCore/testing
diff options
context:
space:
mode:
authorSimon Hausmann <simon.hausmann@nokia.com>2012-02-03 09:55:33 +0100
committerSimon Hausmann <simon.hausmann@nokia.com>2012-02-03 09:55:33 +0100
commitcd44dc59cdfc39534aef4d417e9f3c412e3be139 (patch)
tree8d89889ba95ed6ec9322e733846cc9cce9d7dff1 /Source/WebCore/testing
parentd11f84f5b5cdc0d92a08af01b13472fdd5f9acb9 (diff)
downloadqtwebkit-cd44dc59cdfc39534aef4d417e9f3c412e3be139.tar.gz
Imported WebKit commit fce473cb4d55aa9fe9d0b0322a2fffecb731b961 (http://svn.webkit.org/repository/webkit/trunk@106560)
Diffstat (limited to 'Source/WebCore/testing')
-rw-r--r--Source/WebCore/testing/InternalSettings.cpp274
-rw-r--r--Source/WebCore/testing/InternalSettings.h83
-rw-r--r--Source/WebCore/testing/InternalSettings.idl49
-rw-r--r--Source/WebCore/testing/Internals.cpp310
-rw-r--r--Source/WebCore/testing/Internals.h63
-rw-r--r--Source/WebCore/testing/Internals.idl38
-rw-r--r--Source/WebCore/testing/js/JSInternalsCustom.cpp67
-rw-r--r--Source/WebCore/testing/js/WebCoreTestSupport.cpp5
-rw-r--r--Source/WebCore/testing/v8/V8InternalsCustom.cpp66
-rw-r--r--Source/WebCore/testing/v8/WebCoreTestSupport.cpp4
10 files changed, 676 insertions, 283 deletions
diff --git a/Source/WebCore/testing/InternalSettings.cpp b/Source/WebCore/testing/InternalSettings.cpp
new file mode 100644
index 000000000..a4dbb44bf
--- /dev/null
+++ b/Source/WebCore/testing/InternalSettings.cpp
@@ -0,0 +1,274 @@
+/*
+ * Copyright (C) 2012 Google 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.
+ *
+ * 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 "config.h"
+#include "InternalSettings.h"
+
+#include "CachedResourceLoader.h"
+#include "Document.h"
+#include "ExceptionCode.h"
+#include "Frame.h"
+#include "FrameView.h"
+#include "InspectorController.h"
+#include "Language.h"
+#include "Page.h"
+#include "Settings.h"
+
+#if ENABLE(GESTURE_EVENTS)
+#include "PlatformGestureEvent.h"
+#endif
+
+#if ENABLE(SMOOTH_SCROLLING)
+#include "ScrollAnimator.h"
+#endif
+
+#if ENABLE(INPUT_COLOR)
+#include "ColorChooser.h"
+#endif
+
+#define InternalSettingsGuardForSettingsReturn(returnValue) \
+ if (!settings()) { \
+ ec = INVALID_ACCESS_ERR; \
+ return returnValue; \
+ }
+
+#define InternalSettingsGuardForSettings() \
+ if (!settings()) { \
+ ec = INVALID_ACCESS_ERR; \
+ return; \
+ }
+
+#define InternalSettingsGuardForFrame() \
+ if (!frame()) { \
+ ec = INVALID_ACCESS_ERR; \
+ return; \
+ }
+
+#define InternalSettingsGuardForFrameView() \
+ if (!frame() || !frame()->view()) { \
+ ec = INVALID_ACCESS_ERR; \
+ return; \
+ }
+
+#define InternalSettingsGuardForPageReturn(returnValue) \
+ if (!page()) { \
+ ec = INVALID_ACCESS_ERR; \
+ return returnValue; \
+ }
+
+#define InternalSettingsGuardForPage() \
+ if (!page()) { \
+ ec = INVALID_ACCESS_ERR; \
+ return; \
+ }
+
+namespace WebCore {
+
+
+PassRefPtr<InternalSettings> InternalSettings::create(Frame* frame, InternalSettings* old)
+{
+ return adoptRef(new InternalSettings(frame, old));
+}
+
+InternalSettings::~InternalSettings()
+{
+}
+
+InternalSettings::InternalSettings(Frame* frame, InternalSettings* old)
+ : FrameDestructionObserver(frame)
+ , m_passwordEchoDurationInSecondsBackup(0)
+ , m_passwordEchoDurationInSecondsBackedUp(false)
+ , m_passwordEchoEnabledBackedUp(false)
+{
+ if (old && settings()) {
+ if (old->m_passwordEchoDurationInSecondsBackedUp)
+ settings()->setPasswordEchoDurationInSeconds(old->m_passwordEchoDurationInSecondsBackup);
+ if (old->m_passwordEchoEnabledBackedUp)
+ settings()->setPasswordEchoEnabled(old->m_passwordEchoEnabledBackup);
+ }
+}
+
+Settings* InternalSettings::settings() const
+{
+ if (!frame() || !frame()->page())
+ return 0;
+ return frame()->page()->settings();
+}
+
+Document* InternalSettings::document() const
+{
+ return frame() ? frame()->document() : 0;
+}
+
+Page* InternalSettings::page() const
+{
+ return document() ? document()->page() : 0;
+}
+
+void InternalSettings::setInspectorResourcesDataSizeLimits(int maximumResourcesContentSize, int maximumSingleResourceContentSize, ExceptionCode& ec)
+{
+#if ENABLE(INSPECTOR)
+ if (!page() || !page()->inspectorController()) {
+ ec = INVALID_ACCESS_ERR;
+ return;
+ }
+ page()->inspectorController()->setResourcesDataSizeLimitsFromInternals(maximumResourcesContentSize, maximumSingleResourceContentSize);
+#else
+ UNUSED_PARAM(maximumResourcesContentSize);
+ UNUSED_PARAM(maximumSingleResourceContentSize);
+ UNUSED_PARAM(ec);
+#endif
+}
+
+void InternalSettings::setForceCompositingMode(bool enabled, ExceptionCode& ec)
+{
+ InternalSettingsGuardForSettings();
+ settings()->setForceCompositingMode(enabled);
+}
+
+void InternalSettings::setAcceleratedFiltersEnabled(bool enabled, ExceptionCode& ec)
+{
+ InternalSettingsGuardForSettings();
+ settings()->setAcceleratedFiltersEnabled(enabled);
+}
+
+void InternalSettings::setEnableCompositingForFixedPosition(bool enabled, ExceptionCode& ec)
+{
+ InternalSettingsGuardForSettings();
+ settings()->setAcceleratedCompositingForFixedPositionEnabled(enabled);
+}
+
+void InternalSettings::setEnableCompositingForScrollableFrames(bool enabled, ExceptionCode& ec)
+{
+ InternalSettingsGuardForSettings();
+ settings()->setAcceleratedCompositingForScrollableFramesEnabled(enabled);
+}
+
+void InternalSettings::setAcceleratedDrawingEnabled(bool enabled, ExceptionCode& ec)
+{
+ InternalSettingsGuardForSettings();
+ settings()->setAcceleratedDrawingEnabled(enabled);
+}
+
+void InternalSettings::setEnableScrollAnimator(bool enabled, ExceptionCode& ec)
+{
+ InternalSettingsGuardForSettings();
+#if ENABLE(SMOOTH_SCROLLING)
+ settings()->setEnableScrollAnimator(enabled);
+#else
+ UNUSED_PARAM(enabled);
+#endif
+}
+
+void InternalSettings::setZoomAnimatorTransform(float scale, float tx, float ty, ExceptionCode& ec)
+{
+ InternalSettingsGuardForFrame();
+
+#if ENABLE(GESTURE_EVENTS)
+ PlatformGestureEvent pge(PlatformEvent::GestureDoubleTap, IntPoint(tx, ty), IntPoint(tx, ty), 0, scale, 0.f, 0, 0, 0, 0);
+ frame()->eventHandler()->handleGestureEvent(pge);
+#else
+ UNUSED_PARAM(scale);
+ UNUSED_PARAM(tx);
+ UNUSED_PARAM(ty);
+#endif
+}
+
+void InternalSettings::setZoomParameters(float scale, float x, float y, ExceptionCode& ec)
+{
+ InternalSettingsGuardForFrameView();
+
+#if ENABLE(SMOOTH_SCROLLING)
+ frame()->view()->scrollAnimator()->setZoomParametersForTest(scale, x, y);
+#else
+ UNUSED_PARAM(scale);
+ UNUSED_PARAM(x);
+ UNUSED_PARAM(y);
+#endif
+}
+
+void InternalSettings::setMockScrollbarsEnabled(bool enabled, ExceptionCode& ec)
+{
+ InternalSettingsGuardForSettings();
+ settings()->setMockScrollbarsEnabled(enabled);
+}
+
+void InternalSettings::setPasswordEchoEnabled(bool enabled, ExceptionCode& ec)
+{
+ InternalSettingsGuardForSettings();
+ if (!m_passwordEchoEnabledBackedUp) {
+ m_passwordEchoEnabledBackup = settings()->passwordEchoEnabled();
+ m_passwordEchoEnabledBackedUp = true;
+ }
+ settings()->setPasswordEchoEnabled(enabled);
+}
+
+void InternalSettings::setPasswordEchoDurationInSeconds(double durationInSeconds, ExceptionCode& ec)
+{
+ InternalSettingsGuardForSettings();
+ if (!m_passwordEchoDurationInSecondsBackedUp) {
+ m_passwordEchoDurationInSecondsBackup = settings()->passwordEchoDurationInSeconds();
+ m_passwordEchoDurationInSecondsBackedUp = true;
+ }
+ settings()->setPasswordEchoDurationInSeconds(durationInSeconds);
+}
+
+void InternalSettings::setFixedElementsLayoutRelativeToFrame(bool enabled, ExceptionCode& ec)
+{
+ InternalSettingsGuardForFrameView();
+ settings()->setFixedElementsLayoutRelativeToFrame(enabled);
+}
+
+void InternalSettings::setUnifiedTextCheckingEnabled(bool enabled, ExceptionCode& ec)
+{
+ InternalSettingsGuardForSettings();
+ settings()->setUnifiedTextCheckerEnabled(enabled);
+}
+
+bool InternalSettings::unifiedTextCheckingEnabled(ExceptionCode& ec)
+{
+ InternalSettingsGuardForSettingsReturn(false);
+ return settings()->unifiedTextCheckerEnabled();
+}
+
+float InternalSettings::pageScaleFactor(ExceptionCode& ec)
+{
+ InternalSettingsGuardForPageReturn(0);
+ return page()->pageScaleFactor();
+}
+
+void InternalSettings::setPageScaleFactor(float scaleFactor, int x, int y, ExceptionCode& ec)
+{
+ InternalSettingsGuardForPage();
+ page()->setPageScaleFactor(scaleFactor, IntPoint(x, y));
+}
+
+void InternalSettings::setPerTileDrawingEnabled(bool enabled, ExceptionCode& ec)
+{
+ InternalSettingsGuardForSettings();
+ settings()->setPerTileDrawingEnabled(enabled);
+}
+
+}
diff --git a/Source/WebCore/testing/InternalSettings.h b/Source/WebCore/testing/InternalSettings.h
new file mode 100644
index 000000000..be9328ee7
--- /dev/null
+++ b/Source/WebCore/testing/InternalSettings.h
@@ -0,0 +1,83 @@
+/*
+ * Copyright (C) 2012 Google 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.
+ *
+ * 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 InternalSettings_h
+#define InternalSettings_h
+
+#include "FrameDestructionObserver.h"
+#include <wtf/PassRefPtr.h>
+#include <wtf/RefCounted.h>
+#include <wtf/text/WTFString.h>
+
+namespace WebCore {
+
+typedef int ExceptionCode;
+
+class Frame;
+class Document;
+class Page;
+class Settings;
+
+class InternalSettings : public RefCounted<InternalSettings>,
+ public FrameDestructionObserver {
+public:
+ static PassRefPtr<InternalSettings> create(Frame*, InternalSettings* old);
+ virtual ~InternalSettings();
+
+ void setInspectorResourcesDataSizeLimits(int maximumResourcesContentSize, int maximumSingleResourceContentSize, ExceptionCode&);
+ void setForceCompositingMode(bool enabled, ExceptionCode&);
+ void setEnableCompositingForFixedPosition(bool enabled, ExceptionCode&);
+ void setEnableCompositingForScrollableFrames(bool enabled, ExceptionCode&);
+ void setAcceleratedDrawingEnabled(bool enabled, ExceptionCode&);
+ void setAcceleratedFiltersEnabled(bool enabled, ExceptionCode&);
+ void setEnableScrollAnimator(bool enabled, ExceptionCode&);
+ void setZoomAnimatorTransform(float scale, float tx, float ty, ExceptionCode&);
+ void setZoomParameters(float scale, float x, float y, ExceptionCode&);
+ void setMockScrollbarsEnabled(bool enabled, ExceptionCode&);
+ void setPasswordEchoEnabled(bool enabled, ExceptionCode&);
+ void setPasswordEchoDurationInSeconds(double durationInSeconds, ExceptionCode&);
+ void setFixedElementsLayoutRelativeToFrame(bool, ExceptionCode&);
+ void setUnifiedTextCheckingEnabled(bool, ExceptionCode&);
+ bool unifiedTextCheckingEnabled(ExceptionCode&);
+ float pageScaleFactor(ExceptionCode&);
+ void setPageScaleFactor(float scaleFactor, int x, int y, ExceptionCode&);
+ void setPerTileDrawingEnabled(bool enabled, ExceptionCode&);
+
+private:
+ InternalSettings(Frame*, InternalSettings* old);
+
+ Settings* settings() const;
+ Document* document() const;
+ Page* page() const;
+
+ double m_passwordEchoDurationInSecondsBackup;
+ bool m_passwordEchoEnabledBackup : 1;
+ bool m_passwordEchoDurationInSecondsBackedUp : 1;
+ bool m_passwordEchoEnabledBackedUp : 1;
+};
+
+} // namespace WebCore
+
+#endif
diff --git a/Source/WebCore/testing/InternalSettings.idl b/Source/WebCore/testing/InternalSettings.idl
new file mode 100644
index 000000000..c2f5b2ac7
--- /dev/null
+++ b/Source/WebCore/testing/InternalSettings.idl
@@ -0,0 +1,49 @@
+/*
+ * Copyright (C) 2012 Google 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.
+ *
+ * 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.
+ */
+
+module window {
+ interface [
+ OmitConstructor
+ ] InternalSettings {
+ void setInspectorResourcesDataSizeLimits(in long maximumResourcesContentSize, in long maximumSingleResourceContentSize) raises(DOMException);
+ void setForceCompositingMode(in boolean enabled) raises(DOMException);
+ void setEnableCompositingForFixedPosition(in boolean enabled) raises(DOMException);
+ void setEnableCompositingForScrollableFrames(in boolean enabled) raises(DOMException);
+ void setAcceleratedDrawingEnabled(in boolean enabled) raises(DOMException);
+ void setAcceleratedFiltersEnabled(in boolean enabled) raises(DOMException);
+ void setEnableScrollAnimator(in boolean enabled) raises(DOMException);
+ void setZoomAnimatorTransform(in float scale, in float tx, in float ty) raises(DOMException);
+ void setZoomParameters(in float scale, in float x, in float y) raises(DOMException);
+ void setMockScrollbarsEnabled(in boolean enabled) raises(DOMException);
+ void setPasswordEchoEnabled(in boolean enabled) raises(DOMException);
+ void setPasswordEchoDurationInSeconds(in double durationInSeconds) raises(DOMException);
+ void setFixedElementsLayoutRelativeToFrame(in boolean enabled) raises(DOMException);
+ void setUnifiedTextCheckingEnabled(in boolean enabled) raises (DOMException);
+ boolean unifiedTextCheckingEnabled() raises (DOMException);
+ float pageScaleFactor() raises(DOMException);
+ void setPageScaleFactor(in float scaleFactor, in long x, in long y) raises(DOMException);
+ };
+}
+
diff --git a/Source/WebCore/testing/Internals.cpp b/Source/WebCore/testing/Internals.cpp
index 783c38056..16447fc60 100644
--- a/Source/WebCore/testing/Internals.cpp
+++ b/Source/WebCore/testing/Internals.cpp
@@ -35,18 +35,20 @@
#include "ExceptionCode.h"
#include "Frame.h"
#include "FrameView.h"
+#include "HTMLContentElement.h"
#include "HTMLInputElement.h"
#include "HTMLNames.h"
#include "HTMLTextAreaElement.h"
#include "InspectorController.h"
+#include "InternalSettings.h"
#include "IntRect.h"
+#include "Language.h"
#include "NodeRenderingContext.h"
#include "Page.h"
#include "Range.h"
#include "RenderObject.h"
#include "RenderTreeAsText.h"
#include "Settings.h"
-#include "ShadowContentElement.h"
#include "ShadowRoot.h"
#include "SpellChecker.h"
#include "TextIterator.h"
@@ -103,19 +105,19 @@ static SpellChecker* spellchecker(Document* document)
const char* Internals::internalsId = "internals";
-PassRefPtr<Internals> Internals::create()
+PassRefPtr<Internals> Internals::create(Document* document)
{
- return adoptRef(new Internals);
+ return adoptRef(new Internals(document));
}
Internals::~Internals()
{
}
-Internals::Internals()
- : passwordEchoDurationInSecondsBackedUp(false)
- , passwordEchoEnabledBackedUp(false)
+Internals::Internals(Document* document)
+ : FrameDestructionObserver(0)
{
+ reset(document);
}
bool Internals::isPreloaded(Document* document, const String& url)
@@ -126,14 +128,14 @@ bool Internals::isPreloaded(Document* document, const String& url)
return document->cachedResourceLoader()->isPreloaded(url);
}
-PassRefPtr<Element> Internals::createShadowContentElement(Document* document, ExceptionCode& ec)
+PassRefPtr<Element> Internals::createContentElement(Document* document, ExceptionCode& ec)
{
if (!document) {
ec = INVALID_ACCESS_ERR;
return 0;
}
- return ShadowContentElement::create(document);
+ return HTMLContentElement::create(document);
}
Element* Internals::getElementByIdInShadowRoot(Node* shadowRoot, const String& id, ExceptionCode& ec)
@@ -145,6 +147,16 @@ Element* Internals::getElementByIdInShadowRoot(Node* shadowRoot, const String& i
return toShadowRoot(shadowRoot)->getElementById(id);
}
+bool Internals::isValidContentSelect(Element* contentElement, ExceptionCode& ec)
+{
+ if (!contentElement || !contentElement->isContentElement()) {
+ ec = INVALID_ACCESS_ERR;
+ return false;
+ }
+
+ return toHTMLContentElement(contentElement)->isSelectValid();
+}
+
String Internals::elementRenderTreeAsText(Element* element, ExceptionCode& ec)
{
if (!element) {
@@ -161,7 +173,20 @@ String Internals::elementRenderTreeAsText(Element* element, ExceptionCode& ec)
return representation;
}
-Node* Internals::ensureShadowRoot(Element* host, ExceptionCode& ec)
+size_t Internals::numberOfScopedHTMLStyleChildren(const Element* element, ExceptionCode& ec) const
+{
+ if (element)
+#if ENABLE(STYLE_SCOPED)
+ return element->numberOfScopedHTMLStyleChildren();
+#else
+ return 0;
+#endif
+
+ ec = INVALID_ACCESS_ERR;
+ return 0;
+}
+
+Internals::ShadowRootIfShadowDOMEnabledOrNode* Internals::ensureShadowRoot(Element* host, ExceptionCode& ec)
{
if (!host) {
ec = INVALID_ACCESS_ERR;
@@ -171,7 +196,7 @@ Node* Internals::ensureShadowRoot(Element* host, ExceptionCode& ec)
return host->ensureShadowRoot();
}
-Node* Internals::shadowRoot(Element* host, ExceptionCode& ec)
+Internals::ShadowRootIfShadowDOMEnabledOrNode* Internals::shadowRoot(Element* host, ExceptionCode& ec)
{
if (!host) {
ec = INVALID_ACCESS_ERR;
@@ -223,17 +248,6 @@ void Internals::selectColorInColorChooser(Element* element, const String& colorV
}
#endif
-#if ENABLE(INSPECTOR)
-void Internals::setInspectorResourcesDataSizeLimits(Document* document, int maximumResourcesContentSize, int maximumSingleResourceContentSize, ExceptionCode& ec)
-{
- if (!document || !document->page() || !document->page()->inspectorController()) {
- ec = INVALID_ACCESS_ERR;
- return;
- }
- document->page()->inspectorController()->setResourcesDataSizeLimitsFromInternals(maximumResourcesContentSize, maximumSingleResourceContentSize);
-}
-#endif
-
PassRefPtr<ClientRect> Internals::boundingBox(Element* element, ExceptionCode& ec)
{
if (!element) {
@@ -283,141 +297,6 @@ PassRefPtr<Range> Internals::markerRangeForNode(Node* node, const String& marker
return Range::create(node->document(), node, markers[index]->startOffset(), node, markers[index]->endOffset());
}
-void Internals::setForceCompositingMode(Document* document, bool enabled, ExceptionCode& ec)
-{
- if (!document || !document->settings()) {
- ec = INVALID_ACCESS_ERR;
- return;
- }
-
- document->settings()->setForceCompositingMode(enabled);
-}
-
-void Internals::setEnableCompositingForFixedPosition(Document* document, bool enabled, ExceptionCode& ec)
-{
- if (!document || !document->settings()) {
- ec = INVALID_ACCESS_ERR;
- return;
- }
-
- document->settings()->setAcceleratedCompositingForFixedPositionEnabled(enabled);
-}
-
-void Internals::setEnableCompositingForScrollableFrames(Document* document, bool enabled, ExceptionCode& ec)
-{
- if (!document || !document->settings()) {
- ec = INVALID_ACCESS_ERR;
- return;
- }
-
- document->settings()->setAcceleratedCompositingForScrollableFramesEnabled(enabled);
-}
-
-void Internals::setAcceleratedDrawingEnabled(Document* document, bool enabled, ExceptionCode& ec)
-{
- if (!document || !document->settings()) {
- ec = INVALID_ACCESS_ERR;
- return;
- }
-
- document->settings()->setAcceleratedDrawingEnabled(enabled);
-}
-
-void Internals::setAcceleratedFiltersEnabled(Document* document, bool enabled, ExceptionCode& ec)
-{
- if (!document || !document->settings()) {
- ec = INVALID_ACCESS_ERR;
- return;
- }
-
- document->settings()->setAcceleratedFiltersEnabled(enabled);
-}
-
-void Internals::setEnableScrollAnimator(Document* document, bool enabled, ExceptionCode& ec)
-{
- if (!document || !document->settings()) {
- ec = INVALID_ACCESS_ERR;
- return;
- }
-
-#if ENABLE(SMOOTH_SCROLLING)
- document->settings()->setEnableScrollAnimator(enabled);
-#else
- UNUSED_PARAM(enabled);
-#endif
-}
-
-void Internals::setZoomAnimatorTransform(Document *document, float scale, float tx, float ty, ExceptionCode& ec)
-{
- if (!document || !document->view() || !document->view()->frame()) {
- ec = INVALID_ACCESS_ERR;
- return;
- }
-
-#if ENABLE(GESTURE_EVENTS)
- PlatformGestureEvent pge(PlatformEvent::GestureDoubleTap, IntPoint(tx, ty), IntPoint(tx, ty), 0, scale, 0.f, 0, 0, 0, 0);
- document->view()->frame()->eventHandler()->handleGestureEvent(pge);
-#else
- UNUSED_PARAM(scale);
- UNUSED_PARAM(tx);
- UNUSED_PARAM(ty);
-#endif
-}
-
-void Internals::setZoomParameters(Document* document, float scale, float x, float y, ExceptionCode& ec)
-{
- if (!document || !document->view() || !document->view()->frame()) {
- ec = INVALID_ACCESS_ERR;
- return;
- }
-
-#if ENABLE(SMOOTH_SCROLLING)
- document->view()->scrollAnimator()->setZoomParametersForTest(scale, x, y);
-#else
- UNUSED_PARAM(scale);
- UNUSED_PARAM(x);
- UNUSED_PARAM(y);
-#endif
-}
-
-void Internals::setMockScrollbarsEnabled(Document* document, bool enabled, ExceptionCode& ec)
-{
- if (!document || !document->settings()) {
- ec = INVALID_ACCESS_ERR;
- return;
- }
-
- document->settings()->setMockScrollbarsEnabled(enabled);
-}
-
-void Internals::setPasswordEchoEnabled(Document* document, bool enabled, ExceptionCode& ec)
-{
- if (!document || !document->settings()) {
- ec = INVALID_ACCESS_ERR;
- return;
- }
-
- if (!passwordEchoEnabledBackedUp) {
- passwordEchoEnabledBackup = document->settings()->passwordEchoEnabled();
- passwordEchoEnabledBackedUp = true;
- }
- document->settings()->setPasswordEchoEnabled(enabled);
-}
-
-void Internals::setPasswordEchoDurationInSeconds(Document* document, double durationInSeconds, ExceptionCode& ec)
-{
- if (!document || !document->settings()) {
- ec = INVALID_ACCESS_ERR;
- return;
- }
-
- if (!passwordEchoDurationInSecondsBackedUp) {
- passwordEchoDurationInSecondsBackup = document->settings()->passwordEchoDurationInSeconds();
- passwordEchoDurationInSecondsBackedUp = true;
- }
- document->settings()->setPasswordEchoDurationInSeconds(durationInSeconds);
-}
-
void Internals::setScrollViewPosition(Document* document, long x, long y, ExceptionCode& ec)
{
if (!document || !document->view()) {
@@ -465,16 +344,8 @@ void Internals::reset(Document* document)
if (!document || !document->settings())
return;
- if (passwordEchoDurationInSecondsBackedUp) {
- document->settings()->setPasswordEchoDurationInSeconds(passwordEchoDurationInSecondsBackup);
- passwordEchoDurationInSecondsBackedUp = false;
- }
-
- if (passwordEchoEnabledBackedUp) {
- document->settings()->setPasswordEchoEnabled(passwordEchoEnabledBackup);
- passwordEchoEnabledBackedUp = false;
- }
-
+ observeFrame(document->frame());
+ m_settings = InternalSettings::create(document->frame(), m_settings.get());
if (Page* page = document->page())
page->setPagination(Page::Pagination());
}
@@ -586,56 +457,6 @@ unsigned Internals::lengthFromRange(Element* scope, const Range* range, Exceptio
return length;
}
-void Internals::setShouldLayoutFixedElementsRelativeToFrame(Document* document, bool enabled, ExceptionCode& ec)
-{
- if (!document || !document->view()) {
- ec = INVALID_ACCESS_ERR;
- return;
- }
-
- FrameView* frameView = document->view();
- frameView->setShouldLayoutFixedElementsRelativeToFrame(enabled);
-}
-
-void Internals::setUnifiedTextCheckingEnabled(Document* document, bool enabled, ExceptionCode& ec)
-{
- if (!document || !document->frame() || !document->frame()->settings()) {
- ec = INVALID_ACCESS_ERR;
- return;
- }
-
- document->frame()->settings()->setUnifiedTextCheckerEnabled(enabled);
-}
-
-bool Internals::unifiedTextCheckingEnabled(Document* document, ExceptionCode& ec)
-{
- if (!document || !document->frame() || !document->frame()->settings()) {
- ec = INVALID_ACCESS_ERR;
- return false;
- }
-
- return document->frame()->settings()->unifiedTextCheckerEnabled();
-}
-
-float Internals::pageScaleFactor(Document *document, ExceptionCode& ec)
-{
- if (!document || !document->page()) {
- ec = INVALID_ACCESS_ERR;
- return 0;
- }
-
- return document->page()->pageScaleFactor();
-}
-
-void Internals::setPageScaleFactor(Document* document, float scaleFactor, int x, int y, ExceptionCode& ec)
-{
- if (!document || !document->page()) {
- ec = INVALID_ACCESS_ERR;
- return;
- }
- document->page()->setPageScaleFactor(scaleFactor, IntPoint(x, y));
-}
-
int Internals::lastSpellCheckRequestSequence(Document* document, ExceptionCode& ec)
{
SpellChecker* checker = spellchecker(document);
@@ -660,14 +481,63 @@ int Internals::lastSpellCheckProcessedSequence(Document* document, ExceptionCode
return checker->lastProcessedSequence();
}
-void Internals::setPerTileDrawingEnabled(Document* document, bool enabled, ExceptionCode& ec)
+Vector<String> Internals::userPreferredLanguages() const
+{
+ return WebCore::userPreferredLanguages();
+}
+
+void Internals::setUserPreferredLanguages(const Vector<String>& languages)
+{
+ WebCore::overrideUserPreferredLanguages(languages);
+}
+
+void Internals::setShouldDisplayTrackKind(Document* document, const String& kind, bool enabled, ExceptionCode& ec)
{
- if (!document || !document->settings()) {
+ if (!document || !document->frame() || !document->frame()->settings()) {
ec = INVALID_ACCESS_ERR;
return;
}
-
- document->settings()->setPerTileDrawingEnabled(enabled);
+
+#if ENABLE(VIDEO_TRACK)
+ Settings* settings = document->frame()->settings();
+
+ if (equalIgnoringCase(kind, "Subtitles"))
+ settings->setShouldDisplaySubtitles(enabled);
+ else if (equalIgnoringCase(kind, "Captions"))
+ settings->setShouldDisplayCaptions(enabled);
+ else if (equalIgnoringCase(kind, "TextDescriptions"))
+ settings->setShouldDisplayTextDescriptions(enabled);
+ else
+ ec = SYNTAX_ERR;
+#else
+ UNUSED_PARAM(kind);
+ UNUSED_PARAM(enabled);
+#endif
}
+bool Internals::shouldDisplayTrackKind(Document* document, const String& kind, ExceptionCode& ec)
+{
+ if (!document || !document->frame() || !document->frame()->settings()) {
+ ec = INVALID_ACCESS_ERR;
+ return false;
+ }
+
+#if ENABLE(VIDEO_TRACK)
+ Settings* settings = document->frame()->settings();
+
+ if (equalIgnoringCase(kind, "Subtitles"))
+ return settings->shouldDisplaySubtitles();
+ if (equalIgnoringCase(kind, "Captions"))
+ return settings->shouldDisplayCaptions();
+ if (equalIgnoringCase(kind, "TextDescriptions"))
+ return settings->shouldDisplayTextDescriptions();
+
+ ec = SYNTAX_ERR;
+ return false;
+#else
+ UNUSED_PARAM(kind);
+ return false;
+#endif
+}
+
}
diff --git a/Source/WebCore/testing/Internals.h b/Source/WebCore/testing/Internals.h
index ed4737055..b87253106 100644
--- a/Source/WebCore/testing/Internals.h
+++ b/Source/WebCore/testing/Internals.h
@@ -26,6 +26,7 @@
#ifndef Internals_h
#define Internals_h
+#include "FrameDestructionObserver.h"
#include "PlatformString.h"
#include <wtf/PassRefPtr.h>
#include <wtf/RefCounted.h>
@@ -36,14 +37,17 @@ namespace WebCore {
class ClientRect;
class Document;
class Element;
+class InternalSettings;
class Node;
class Range;
+class ShadowRoot;
typedef int ExceptionCode;
-class Internals : public RefCounted<Internals> {
+class Internals : public RefCounted<Internals>,
+ public FrameDestructionObserver {
public:
- static PassRefPtr<Internals> create();
+ static PassRefPtr<Internals> create(Document*);
virtual ~Internals();
void reset(Document*);
@@ -52,44 +56,31 @@ public:
bool isPreloaded(Document*, const String& url);
- Node* ensureShadowRoot(Element* host, ExceptionCode&);
- Node* shadowRoot(Element* host, ExceptionCode&);
+ size_t numberOfScopedHTMLStyleChildren(const Element*, ExceptionCode&) const;
+
+#if ENABLE(SHADOW_DOM)
+ typedef ShadowRoot ShadowRootIfShadowDOMEnabledOrNode;
+#else
+ typedef Node ShadowRootIfShadowDOMEnabledOrNode;
+#endif
+ ShadowRootIfShadowDOMEnabledOrNode* ensureShadowRoot(Element* host, ExceptionCode&);
+ ShadowRootIfShadowDOMEnabledOrNode* shadowRoot(Element* host, ExceptionCode&);
void removeShadowRoot(Element* host, ExceptionCode&);
Element* includerFor(Node*, ExceptionCode&);
String shadowPseudoId(Element*, ExceptionCode&);
- PassRefPtr<Element> createShadowContentElement(Document*, ExceptionCode&);
+ PassRefPtr<Element> createContentElement(Document*, ExceptionCode&);
Element* getElementByIdInShadowRoot(Node* shadowRoot, const String& id, ExceptionCode&);
+ bool isValidContentSelect(Element* contentElement, ExceptionCode&);
#if ENABLE(INPUT_COLOR)
void selectColorInColorChooser(Element*, const String& colorValue);
#endif
-#if ENABLE(INSPECTOR)
- void setInspectorResourcesDataSizeLimits(Document*, int maximumResourcesContentSize, int maximumSingleResourceContentSize, ExceptionCode&);
-#else
- void setInspectorResourcesDataSizeLimits(Document*, int maximumResourcesContentSize, int maximumSingleResourceContentSize, ExceptionCode&) { }
-#endif
-
PassRefPtr<ClientRect> boundingBox(Element*, ExceptionCode&);
unsigned markerCountForNode(Node*, const String&, ExceptionCode&);
PassRefPtr<Range> markerRangeForNode(Node*, const String&, unsigned, ExceptionCode&);
- void setForceCompositingMode(Document*, bool enabled, ExceptionCode&);
- void setEnableCompositingForFixedPosition(Document*, bool enabled, ExceptionCode&);
- void setEnableCompositingForScrollableFrames(Document*, bool enabled, ExceptionCode&);
- void setAcceleratedDrawingEnabled(Document*, bool enabled, ExceptionCode&);
- void setAcceleratedFiltersEnabled(Document*, bool enabled, ExceptionCode&);
-
- void setEnableScrollAnimator(Document*, bool enabled, ExceptionCode&);
- void setZoomAnimatorTransform(Document*, float scale, float tx, float ty, ExceptionCode&);
- void setZoomParameters(Document*, float scale, float x, float y, ExceptionCode&);
-
- void setMockScrollbarsEnabled(Document*, bool enabled, ExceptionCode&);
-
- void setPasswordEchoEnabled(Document*, bool enabled, ExceptionCode&);
- void setPasswordEchoDurationInSeconds(Document*, double durationInSeconds, ExceptionCode&);
-
void setScrollViewPosition(Document*, long x, long y, ExceptionCode&);
void setPagination(Document*, const String& mode, int gap, ExceptionCode&);
@@ -104,28 +95,24 @@ public:
PassRefPtr<Range> rangeFromLocationAndLength(Element* scope, int rangeLocation, int rangeLength, ExceptionCode&);
unsigned locationFromRange(Element* scope, const Range*, ExceptionCode&);
unsigned lengthFromRange(Element* scope, const Range*, ExceptionCode&);
- void setShouldLayoutFixedElementsRelativeToFrame(Document*, bool, ExceptionCode&);
-
- void setUnifiedTextCheckingEnabled(Document*, bool, ExceptionCode&);
- bool unifiedTextCheckingEnabled(Document*, ExceptionCode&);
int lastSpellCheckRequestSequence(Document*, ExceptionCode&);
int lastSpellCheckProcessedSequence(Document*, ExceptionCode&);
- float pageScaleFactor(Document*, ExceptionCode&);
- void setPageScaleFactor(Document*, float scaleFactor, int x, int y, ExceptionCode&);
+ Vector<String> userPreferredLanguages() const;
+ void setUserPreferredLanguages(const Vector<String>&);
- void setPerTileDrawingEnabled(Document*, bool enabled, ExceptionCode&);
+ void setShouldDisplayTrackKind(Document*, const String& kind, bool, ExceptionCode&);
+ bool shouldDisplayTrackKind(Document*, const String& kind, ExceptionCode&);
static const char* internalsId;
+ InternalSettings* settings() const { return m_settings.get(); }
+
private:
- Internals();
+ explicit Internals(Document*);
- double passwordEchoDurationInSecondsBackup;
- bool passwordEchoEnabledBackup : 1;
- bool passwordEchoDurationInSecondsBackedUp : 1;
- bool passwordEchoEnabledBackedUp : 1;
+ RefPtr<InternalSettings> m_settings;
};
} // namespace WebCore
diff --git a/Source/WebCore/testing/Internals.idl b/Source/WebCore/testing/Internals.idl
index f56d1af74..da081f5aa 100644
--- a/Source/WebCore/testing/Internals.idl
+++ b/Source/WebCore/testing/Internals.idl
@@ -30,37 +30,30 @@ module window {
DOMString elementRenderTreeAsText(in Element element) raises(DOMException);
boolean isPreloaded(in Document document, in DOMString url);
+ unsigned long numberOfScopedHTMLStyleChildren(in Element element) raises(DOMException);
+
+#if defined(ENABLE_SHADOW_DOM)
+ ShadowRoot ensureShadowRoot(in Element host) raises (DOMException);
+ ShadowRoot shadowRoot(in Element host) raises (DOMException);
+#else
Node ensureShadowRoot(in Element host) raises (DOMException);
Node shadowRoot(in Element host) raises (DOMException);
+#endif
Element includerFor(in Node node) raises (DOMException);
void removeShadowRoot(in Element host) raises (DOMException);
DOMString shadowPseudoId(in Element element) raises (DOMException);
- Element createShadowContentElement(in Document document) raises(DOMException);
+ Element createContentElement(in Document document) raises(DOMException);
Element getElementByIdInShadowRoot(in Node shadowRoot, in DOMString id) raises(DOMException);
+ boolean isValidContentSelect(in Element contentElement) raises(DOMException);
#if defined(ENABLE_INPUT_COLOR) && ENABLE_INPUT_COLOR
void selectColorInColorChooser(in Element element, in DOMString colorValue);
#endif
- void setInspectorResourcesDataSizeLimits(in Document document, in long maximumResourcesContentSize, in long maximumSingleResourceContentSize) raises(DOMException);
-
ClientRect boundingBox(in Element element) raises(DOMException);
unsigned long markerCountForNode(in Node node, in DOMString markerType) raises(DOMException);
Range markerRangeForNode(in Node node, in DOMString markerType, in unsigned long index) raises(DOMException);
- void setForceCompositingMode(in Document document, in boolean enabled) raises(DOMException);
- void setEnableCompositingForFixedPosition(in Document document, in boolean enabled) raises(DOMException);
- void setEnableCompositingForScrollableFrames(in Document document, in boolean enabled) raises(DOMException);
- void setAcceleratedDrawingEnabled(in Document document, in boolean enabled) raises(DOMException);
- void setAcceleratedFiltersEnabled(in Document document, in boolean enabled) raises(DOMException);
- void setEnableScrollAnimator(in Document document, in boolean enabled) raises(DOMException);
- void setZoomAnimatorTransform(in Document document, in float scale, in float tx, in float ty) raises(DOMException);
- void setZoomParameters(in Document document, in float scale, in float x, in float y) raises(DOMException);
- void setMockScrollbarsEnabled(in Document document, in boolean enabled) raises(DOMException);
-
- void setPasswordEchoEnabled(in Document document, in boolean enabled) raises(DOMException);
- void setPasswordEchoDurationInSeconds(in Document document, in double durationInSeconds) raises(DOMException);
-
void setScrollViewPosition(in Document document, in long x, in long y) raises(DOMException);
void setPagination(in Document document, in DOMString mode, in long gap) raises(DOMException);
@@ -77,15 +70,16 @@ module window {
unsigned long locationFromRange(in Element scope, in Range range) raises (DOMException);
unsigned long lengthFromRange(in Element scope, in Range range) raises (DOMException);
- void setShouldLayoutFixedElementsRelativeToFrame(in Document document, in boolean enabled) raises(DOMException);
- void setUnifiedTextCheckingEnabled(in Document document, in boolean enabled) raises (DOMException);
- boolean unifiedTextCheckingEnabled(in Document document) raises (DOMException);
-
long lastSpellCheckRequestSequence(in Document document) raises (DOMException);
long lastSpellCheckProcessedSequence(in Document document) raises (DOMException);
- float pageScaleFactor(in Document document) raises(DOMException);
- void setPageScaleFactor(in Document document, in float scaleFactor, in long x, in long y) raises(DOMException);
+#if defined(ENABLE_VIDEO_TRACK) && ENABLE_VIDEO_TRACK
+ void setShouldDisplayTrackKind(in Document document, in DOMString kind, in boolean enabled) raises (DOMException);
+ boolean shouldDisplayTrackKind(in Document document, in DOMString trackKind) raises (DOMException);
+#endif
+ attribute [Custom] Array userPreferredLanguages;
+
+ readonly attribute InternalSettings settings;
};
}
diff --git a/Source/WebCore/testing/js/JSInternalsCustom.cpp b/Source/WebCore/testing/js/JSInternalsCustom.cpp
new file mode 100644
index 000000000..000231954
--- /dev/null
+++ b/Source/WebCore/testing/js/JSInternalsCustom.cpp
@@ -0,0 +1,67 @@
+/*
+ * Copyright (C) 2012 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.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``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 COMPUTER, INC. OR
+ * 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 "config.h"
+#include "JSInternals.h"
+
+#include <runtime/Error.h>
+
+using namespace JSC;
+
+namespace WebCore {
+
+JSValue JSInternals::userPreferredLanguages(ExecState* exec) const
+{
+ Internals* imp = static_cast<Internals*>(impl());
+ const Vector<String> languages = imp->userPreferredLanguages();
+ if (languages.isEmpty())
+ return jsNull();
+
+ MarkedArgumentBuffer array;
+ Vector<String>::const_iterator end = languages.end();
+ for (Vector<String>::const_iterator it = languages.begin(); it != end; ++it)
+ array.append(jsString(exec, stringToUString(*it)));
+ return constructArray(exec, globalObject(), array);
+}
+
+void JSInternals::setUserPreferredLanguages(ExecState* exec, JSValue value)
+{
+ if (!isJSArray(value)) {
+ throwError(exec, createSyntaxError(exec, "setUserPreferredLanguages: Expected Array"));
+ return;
+ }
+
+ Vector<String> languages;
+ JSArray* array = asArray(value);
+ for (unsigned i = 0; i < array->length(); ++i) {
+ String language = ustringToString(array->getIndex(i).toString(exec)->value(exec));
+ languages.append(language);
+ }
+
+ Internals* imp = static_cast<Internals*>(impl());
+ imp->setUserPreferredLanguages(languages);
+}
+
+} // namespace WebCore
diff --git a/Source/WebCore/testing/js/WebCoreTestSupport.cpp b/Source/WebCore/testing/js/WebCoreTestSupport.cpp
index 8a795bf2f..1d2a4575b 100644
--- a/Source/WebCore/testing/js/WebCoreTestSupport.cpp
+++ b/Source/WebCore/testing/js/WebCoreTestSupport.cpp
@@ -27,7 +27,6 @@
#include "WebCoreTestSupport.h"
#include "Internals.h"
-#include "JSDOMGlobalObject.h"
#include "JSDocument.h"
#include "JSInternals.h"
#include <JavaScriptCore/APICast.h>
@@ -43,7 +42,9 @@ void injectInternalsObject(JSContextRef context)
JSLock lock(SilenceAssertionsOnly);
ExecState* exec = toJS(context);
JSDOMGlobalObject* globalObject = static_cast<JSDOMGlobalObject*>(exec->lexicalGlobalObject());
- globalObject->putDirect(exec->globalData(), Identifier(exec, Internals::internalsId), toJS(exec, globalObject, Internals::create()));
+ ScriptExecutionContext* scriptContext = globalObject->scriptExecutionContext();
+ Document* document = scriptContext->isDocument() ? static_cast<Document*>(scriptContext) : 0;
+ globalObject->putDirect(exec->globalData(), Identifier(exec, Internals::internalsId), toJS(exec, globalObject, Internals::create(document)));
}
void resetInternalsObject(JSContextRef context)
diff --git a/Source/WebCore/testing/v8/V8InternalsCustom.cpp b/Source/WebCore/testing/v8/V8InternalsCustom.cpp
new file mode 100644
index 000000000..b6147b589
--- /dev/null
+++ b/Source/WebCore/testing/v8/V8InternalsCustom.cpp
@@ -0,0 +1,66 @@
+/*
+ * Copyright (C) 2012 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.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``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 COMPUTER, INC. OR
+ * 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 "config.h"
+#include "V8Internals.h"
+
+#include "V8Binding.h"
+#include "V8Proxy.h"
+
+namespace WebCore {
+
+v8::Handle<v8::Value> V8Internals::userPreferredLanguagesAccessorGetter(v8::Local<v8::String> name, const v8::AccessorInfo& info)
+{
+ Internals* internals = V8Internals::toNative(info.Holder());
+ const Vector<String> languages = internals->userPreferredLanguages();
+ if (languages.isEmpty())
+ return v8::Null();
+
+ v8::Local<v8::Array> array = v8::Array::New(languages.size());
+ Vector<String>::const_iterator end = languages.end();
+ int index = 0;
+ for (Vector<String>::const_iterator iter = languages.begin(); iter != end; ++iter)
+ array->Set(v8::Integer::New(index++), v8String(*iter));
+ return array;
+}
+
+void V8Internals::userPreferredLanguagesAccessorSetter(v8::Local<v8::String> name, v8::Local<v8::Value> value, const v8::AccessorInfo& info)
+{
+ if (!value->IsArray()) {
+ throwError("setUserPreferredLanguages: Expected Array");
+ return;
+ }
+
+ Vector<String> languages;
+
+ v8::Local<v8::Array> array = v8::Local<v8::Array>::Cast(value);
+ for (size_t i = 0; i < array->Length(); ++i)
+ languages.append(toWebCoreString(array->Get(i)));
+
+ Internals* internals = V8Internals::toNative(info.Holder());
+ internals->setUserPreferredLanguages(languages);
+}
+
+} // namespace WebCore
diff --git a/Source/WebCore/testing/v8/WebCoreTestSupport.cpp b/Source/WebCore/testing/v8/WebCoreTestSupport.cpp
index 76302ed82..28c3729f3 100644
--- a/Source/WebCore/testing/v8/WebCoreTestSupport.cpp
+++ b/Source/WebCore/testing/v8/WebCoreTestSupport.cpp
@@ -42,7 +42,9 @@ void injectInternalsObject(v8::Local<v8::Context> context)
v8::Context::Scope contextScope(context);
v8::HandleScope scope;
- context->Global()->Set(v8::String::New(Internals::internalsId), toV8(Internals::create()));
+ ScriptExecutionContext* scriptContext = getScriptExecutionContext();
+ Document* document = scriptContext->isDocument() ? static_cast<Document*>(scriptContext) : 0;
+ context->Global()->Set(v8::String::New(Internals::internalsId), toV8(Internals::create(document)));
}
void resetInternalsObject(v8::Local<v8::Context> context)