summaryrefslogtreecommitdiff
path: root/Source/WebKit/chromium/tests
diff options
context:
space:
mode:
Diffstat (limited to 'Source/WebKit/chromium/tests')
-rw-r--r--Source/WebKit/chromium/tests/Canvas2DLayerManagerTest.cpp94
-rw-r--r--Source/WebKit/chromium/tests/DateTimeFormatTest.cpp6
-rw-r--r--Source/WebKit/chromium/tests/GraphicsLayerChromiumTest.cpp2
-rw-r--r--Source/WebKit/chromium/tests/IDBDatabaseBackendTest.cpp6
-rw-r--r--Source/WebKit/chromium/tests/IDBFakeBackingStore.h8
-rw-r--r--Source/WebKit/chromium/tests/IDBRequestTest.cpp15
-rw-r--r--Source/WebKit/chromium/tests/ImageLayerChromiumTest.cpp2
-rw-r--r--Source/WebKit/chromium/tests/LocaleMacTest.cpp62
-rw-r--r--Source/WebKit/chromium/tests/LocaleWinTest.cpp93
-rw-r--r--Source/WebKit/chromium/tests/LocalizedDateICUTest.cpp16
-rw-r--r--Source/WebKit/chromium/tests/LocalizedNumberICUTest.cpp2
-rw-r--r--Source/WebKit/chromium/tests/MemoryInstrumentationTest.cpp443
-rw-r--r--Source/WebKit/chromium/tests/ScrollingCoordinatorChromiumTest.cpp9
-rw-r--r--Source/WebKit/chromium/tests/WebFrameTest.cpp423
-rw-r--r--Source/WebKit/chromium/tests/WebImageTest.cpp9
-rw-r--r--Source/WebKit/chromium/tests/WebInputEventFactoryTestMac.mm84
-rw-r--r--Source/WebKit/chromium/tests/WebPageNewSerializerTest.cpp19
-rw-r--r--Source/WebKit/chromium/tests/WebSocketExtensionDispatcherTest.cpp44
-rw-r--r--Source/WebKit/chromium/tests/WebViewTest.cpp40
-rw-r--r--Source/WebKit/chromium/tests/data/clipped-body.html21
-rw-r--r--Source/WebKit/chromium/tests/data/find_in_page.html2
-rw-r--r--Source/WebKit/chromium/tests/data/get_multiple_divs_for_auto_zoom_test.html10
-rw-r--r--Source/WebKit/chromium/tests/data/get_scale_bounds_check_for_auto_zoom_test.html7
-rw-r--r--Source/WebKit/chromium/tests/data/get_scale_for_auto_zoom_into_div_test.html13
-rw-r--r--Source/WebKit/chromium/tests/data/get_scale_for_zoom_into_editable_test.html16
-rw-r--r--Source/WebKit/chromium/tests/data/longpress_selection.html23
-rw-r--r--Source/WebKit/chromium/tests/data/pageserializer/green_rectangle.svg11
-rw-r--r--Source/WebKit/chromium/tests/data/pageserializer/page_with_svg_image.html6
-rwxr-xr-xSource/WebKit/chromium/tests/data/valid_header_missing_bitmap.icobin0 -> 23 bytes
29 files changed, 863 insertions, 623 deletions
diff --git a/Source/WebKit/chromium/tests/Canvas2DLayerManagerTest.cpp b/Source/WebKit/chromium/tests/Canvas2DLayerManagerTest.cpp
index f9a136c35..79e57039a 100644
--- a/Source/WebKit/chromium/tests/Canvas2DLayerManagerTest.cpp
+++ b/Source/WebKit/chromium/tests/Canvas2DLayerManagerTest.cpp
@@ -30,6 +30,8 @@
#include "GraphicsContext3DPrivate.h"
#include <gmock/gmock.h>
#include <gtest/gtest.h>
+#include <public/Platform.h>
+#include <public/WebThread.h>
using namespace WebCore;
using testing::InSequence;
@@ -47,6 +49,15 @@ public:
{
}
+ virtual size_t storageAllocatedForRecording() OVERRIDE
+ {
+ // Because the fake layer has no canvas to query, just
+ // return status quo. Allocation changes that would normally be
+ // initiated by the canvas can be faked by invoking
+ // storageAllocatedForRecordingChanged directly from the test code.
+ return m_bytesAllocated;
+ }
+
void fakeFreeableBytes(size_t size)
{
m_freeableBytes = size;
@@ -65,6 +76,7 @@ public:
virtual void flush() OVERRIDE
{
+ flushedDrawCommands();
m_flushCount++;
}
@@ -133,6 +145,83 @@ protected:
EXPECT_EQ((size_t)11, layer.bytesAllocated()); // flush drops the layer from manager's tracking list
EXPECT_FALSE(manager.isInList(&layer));
}
+
+ void doDeferredFrameTestTask(FakeCanvas2DLayerBridge* layer, bool skipCommands)
+ {
+ EXPECT_FALSE(Canvas2DLayerManager::get().m_taskObserverActive);
+ layer->contextAcquired();
+ layer->storageAllocatedForRecordingChanged(1);
+ EXPECT_TRUE(Canvas2DLayerManager::get().m_taskObserverActive);
+ if (skipCommands) {
+ layer->contextAcquired();
+ layer->storageAllocatedForRecordingChanged(0);
+ layer->skippedPendingDrawCommands();
+ }
+ WebKit::Platform::current()->currentThread()->exitRunLoop();
+ }
+
+ class DeferredFrameTestTask : public WebKit::WebThread::Task {
+ public:
+ DeferredFrameTestTask(Canvas2DLayerManagerTest* test, FakeCanvas2DLayerBridge* layer, bool skipCommands)
+ {
+ m_test = test;
+ m_layer = layer;
+ m_skipCommands = skipCommands;
+ }
+
+ virtual void run() OVERRIDE
+ {
+ m_test->doDeferredFrameTestTask(m_layer, m_skipCommands);
+ }
+ private:
+ Canvas2DLayerManagerTest* m_test;
+ FakeCanvas2DLayerBridge* m_layer;
+ bool m_skipCommands;
+ };
+
+ void deferredFrameTest()
+ {
+ Canvas2DLayerManager::get().init(10, 10);
+ FakeCanvas2DLayerBridge fakeLayer;
+ WebKit::Platform::current()->currentThread()->postTask(new DeferredFrameTestTask(this, &fakeLayer, true));
+ WebKit::Platform::current()->currentThread()->enterRunLoop();
+ // Verify that didProcessTask was called upon completion
+ EXPECT_FALSE(Canvas2DLayerManager::get().m_taskObserverActive);
+ // Verify that no flush was performed because frame is fresh
+ EXPECT_EQ(0, fakeLayer.m_flushCount);
+
+ // Verify that no flushes are triggered as long as frame are fresh
+ WebKit::Platform::current()->currentThread()->postTask(new DeferredFrameTestTask(this, &fakeLayer, true));
+ WebKit::Platform::current()->currentThread()->enterRunLoop();
+ EXPECT_FALSE(Canvas2DLayerManager::get().m_taskObserverActive);
+ EXPECT_EQ(0, fakeLayer.m_flushCount);
+
+ WebKit::Platform::current()->currentThread()->postTask(new DeferredFrameTestTask(this, &fakeLayer, true));
+ WebKit::Platform::current()->currentThread()->enterRunLoop();
+ EXPECT_FALSE(Canvas2DLayerManager::get().m_taskObserverActive);
+ EXPECT_EQ(0, fakeLayer.m_flushCount);
+
+ // Verify that a flush is triggered every two frames when they are stale.
+ WebKit::Platform::current()->currentThread()->postTask(new DeferredFrameTestTask(this, &fakeLayer, false));
+ WebKit::Platform::current()->currentThread()->enterRunLoop();
+ EXPECT_FALSE(Canvas2DLayerManager::get().m_taskObserverActive);
+ EXPECT_EQ(1, fakeLayer.m_flushCount);
+
+ WebKit::Platform::current()->currentThread()->postTask(new DeferredFrameTestTask(this, &fakeLayer, false));
+ WebKit::Platform::current()->currentThread()->enterRunLoop();
+ EXPECT_FALSE(Canvas2DLayerManager::get().m_taskObserverActive);
+ EXPECT_EQ(1, fakeLayer.m_flushCount);
+
+ WebKit::Platform::current()->currentThread()->postTask(new DeferredFrameTestTask(this, &fakeLayer, false));
+ WebKit::Platform::current()->currentThread()->enterRunLoop();
+ EXPECT_FALSE(Canvas2DLayerManager::get().m_taskObserverActive);
+ EXPECT_EQ(2, fakeLayer.m_flushCount);
+
+ WebKit::Platform::current()->currentThread()->postTask(new DeferredFrameTestTask(this, &fakeLayer, false));
+ WebKit::Platform::current()->currentThread()->enterRunLoop();
+ EXPECT_FALSE(Canvas2DLayerManager::get().m_taskObserverActive);
+ EXPECT_EQ(2, fakeLayer.m_flushCount);
+ }
};
namespace {
@@ -152,5 +241,10 @@ TEST_F(Canvas2DLayerManagerTest, testFlushEviction)
flushEvictionTest();
}
+TEST_F(Canvas2DLayerManagerTest, testDeferredFrame)
+{
+ deferredFrameTest();
+}
+
} // namespace
diff --git a/Source/WebKit/chromium/tests/DateTimeFormatTest.cpp b/Source/WebKit/chromium/tests/DateTimeFormatTest.cpp
index 1c006abaf..a2c5e9f0a 100644
--- a/Source/WebKit/chromium/tests/DateTimeFormatTest.cpp
+++ b/Source/WebKit/chromium/tests/DateTimeFormatTest.cpp
@@ -26,7 +26,7 @@
#include "config.h"
#include "DateTimeFormat.h"
-#if ENABLE(INPUT_TYPE_TIME_MULTIPLE_FIELDS)
+#if ENABLE(INPUT_MULTIPLE_FIELDS_UI)
#include <gtest/gtest.h>
#include <wtf/text/CString.h>
#include <wtf/text/StringBuilder.h>
@@ -280,7 +280,7 @@ TEST_F(DateTimeFormatTest, SingleLowerCaseCharacter)
EXPECT_EQ(DateTimeFormat::FieldTypeSecond, single('s'));
EXPECT_EQ(DateTimeFormat::FieldTypeExtendedYear, single('u'));
EXPECT_EQ(DateTimeFormat::FieldTypeNonLocationZone, single('v'));
- EXPECT_EQ(DateTimeFormat::FieldTypeWeekOfMonth, single('w'));
+ EXPECT_EQ(DateTimeFormat::FieldTypeWeekOfMonth, single('W'));
EXPECT_EQ(DateTimeFormat::FieldTypeYear, single('y'));
EXPECT_EQ(DateTimeFormat::FieldTypeZone, single('z'));
}
@@ -313,7 +313,7 @@ TEST_F(DateTimeFormatTest, SingleUpperCaseCharacter)
EXPECT_EQ(DateTimeFormat::FieldTypeMonth, single('M'));
EXPECT_EQ(DateTimeFormat::FieldTypeQuater, single('Q'));
EXPECT_EQ(DateTimeFormat::FieldTypeFractionalSecond, single('S'));
- EXPECT_EQ(DateTimeFormat::FieldTypeWeekOfYear, single('W'));
+ EXPECT_EQ(DateTimeFormat::FieldTypeWeekOfYear, single('w'));
EXPECT_EQ(DateTimeFormat::FieldTypeYearOfWeekOfYear, single('Y'));
EXPECT_EQ(DateTimeFormat::FieldTypeRFC822Zone, single('Z'));
}
diff --git a/Source/WebKit/chromium/tests/GraphicsLayerChromiumTest.cpp b/Source/WebKit/chromium/tests/GraphicsLayerChromiumTest.cpp
index 812246e57..0ce84257b 100644
--- a/Source/WebKit/chromium/tests/GraphicsLayerChromiumTest.cpp
+++ b/Source/WebKit/chromium/tests/GraphicsLayerChromiumTest.cpp
@@ -50,7 +50,7 @@ namespace {
class MockGraphicsLayerClient : public GraphicsLayerClient {
public:
virtual void notifyAnimationStarted(const GraphicsLayer*, double time) OVERRIDE { }
- virtual void notifySyncRequired(const GraphicsLayer*) OVERRIDE { }
+ virtual void notifyFlushRequired(const GraphicsLayer*) OVERRIDE { }
virtual void paintContents(const GraphicsLayer*, GraphicsContext&, GraphicsLayerPaintingPhase, const IntRect& inClip) OVERRIDE { }
virtual bool showDebugBorders(const GraphicsLayer*) const OVERRIDE { return false; }
virtual bool showRepaintCounter(const GraphicsLayer*) const OVERRIDE { return false; }
diff --git a/Source/WebKit/chromium/tests/IDBDatabaseBackendTest.cpp b/Source/WebKit/chromium/tests/IDBDatabaseBackendTest.cpp
index b6b36671d..2cf2a1f88 100644
--- a/Source/WebKit/chromium/tests/IDBDatabaseBackendTest.cpp
+++ b/Source/WebKit/chromium/tests/IDBDatabaseBackendTest.cpp
@@ -57,12 +57,12 @@ TEST(IDBDatabaseBackendTest, BackingStoreRetention)
EXPECT_GT(backingStore->refCount(), 1);
const bool autoIncrement = false;
- RefPtr<IDBObjectStoreBackendImpl> store = IDBObjectStoreBackendImpl::create(db.get(), "store", IDBKeyPath("keyPath"), autoIncrement);
+ RefPtr<IDBObjectStoreBackendImpl> store = IDBObjectStoreBackendImpl::create(db.get(), 1, "store", IDBKeyPath("keyPath"), autoIncrement, 0);
EXPECT_GT(backingStore->refCount(), 1);
const bool unique = false;
const bool multiEntry = false;
- RefPtr<IDBIndexBackendImpl> index = IDBIndexBackendImpl::create(db.get(), store.get(), "index", IDBKeyPath("keyPath"), unique, multiEntry);
+ RefPtr<IDBIndexBackendImpl> index = IDBIndexBackendImpl::create(db.get(), store.get(), -1, "index", IDBKeyPath("keyPath"), unique, multiEntry);
EXPECT_GT(backingStore->refCount(), 1);
db.clear();
@@ -148,7 +148,7 @@ public:
}
virtual IDBDatabaseMetadata metadata() const { return IDBDatabaseMetadata(); }
- virtual PassRefPtr<IDBObjectStoreBackendInterface> createObjectStore(const String& name, const IDBKeyPath&, bool autoIncrement, IDBTransactionBackendInterface*, ExceptionCode&) { return 0; }
+ virtual PassRefPtr<IDBObjectStoreBackendInterface> createObjectStore(int64_t, const String& name, const IDBKeyPath&, bool autoIncrement, IDBTransactionBackendInterface*, ExceptionCode&) { return 0; }
virtual void deleteObjectStore(const String& name, IDBTransactionBackendInterface*, ExceptionCode&) { }
virtual void setVersion(const String& version, PassRefPtr<IDBCallbacks>, PassRefPtr<IDBDatabaseCallbacks>, ExceptionCode&) { }
virtual PassRefPtr<IDBTransactionBackendInterface> transaction(DOMStringList* storeNames, unsigned short mode, ExceptionCode&) { return 0; }
diff --git a/Source/WebKit/chromium/tests/IDBFakeBackingStore.h b/Source/WebKit/chromium/tests/IDBFakeBackingStore.h
index 457ae3745..c59dce675 100644
--- a/Source/WebKit/chromium/tests/IDBFakeBackingStore.h
+++ b/Source/WebKit/chromium/tests/IDBFakeBackingStore.h
@@ -33,14 +33,14 @@ namespace WebCore {
class IDBFakeBackingStore : public IDBBackingStore {
public:
virtual void getDatabaseNames(Vector<String>& foundNames) OVERRIDE { }
- virtual bool getIDBDatabaseMetaData(const String& name, String& foundVersion, int64_t& foundIntVersion, int64_t& foundId) OVERRIDE { return false; }
+ virtual bool getIDBDatabaseMetaData(const String& name, String& foundStringVersion, int64_t& foundIntVersion, int64_t& foundId, int64_t& maxObjectStoreId) OVERRIDE { return false; }
virtual bool createIDBDatabaseMetaData(const String& name, const String& version, int64_t intVersion, int64_t& rowId) OVERRIDE { return true; }
virtual bool updateIDBDatabaseMetaData(Transaction*, int64_t rowId, const String& version) OVERRIDE { return false; }
virtual bool updateIDBDatabaseIntVersion(Transaction*, int64_t rowId, int64_t version) OVERRIDE { return false; }
virtual bool deleteDatabase(const String& name) OVERRIDE { return false; }
- virtual void getObjectStores(int64_t databaseId, Vector<int64_t>& foundIds, Vector<String>& foundNames, Vector<IDBKeyPath>& foundKeyPaths, Vector<bool>& foundAutoIncrementFlags) OVERRIDE { }
- virtual bool createObjectStore(Transaction*, int64_t databaseId, const String& name, const IDBKeyPath& keyPath, bool autoIncrement, int64_t& assignedObjectStoreId) OVERRIDE { return false; }
+ virtual void getObjectStores(int64_t databaseId, Vector<int64_t>& foundIds, Vector<String>& foundNames, Vector<IDBKeyPath>& foundKeyPaths, Vector<bool>& foundAutoIncrementFlags, Vector<int64_t>& foundMaxIndexIds) OVERRIDE { }
+ virtual bool createObjectStore(Transaction*, int64_t databaseId, int64_t objectStoreId, const String& name, const IDBKeyPath&, bool autoIncrement) OVERRIDE { return false; };
virtual void deleteObjectStore(Transaction*, int64_t databaseId, int64_t objectStoreId) OVERRIDE { }
virtual PassRefPtr<ObjectStoreRecordIdentifier> createInvalidRecordIdentifier() OVERRIDE { return PassRefPtr<ObjectStoreRecordIdentifier>(); }
@@ -56,7 +56,7 @@ public:
virtual bool forEachObjectStoreRecord(Transaction*, int64_t databaseId, int64_t objectStoreId, ObjectStoreRecordCallback&) OVERRIDE { return false; }
virtual void getIndexes(int64_t databaseId, int64_t objectStoreId, Vector<int64_t>& foundIds, Vector<String>& foundNames, Vector<IDBKeyPath>& foundKeyPaths, Vector<bool>& foundUniqueFlags, Vector<bool>& foundMultiEntryFlags) OVERRIDE { }
- virtual bool createIndex(Transaction*, int64_t databaseId, int64_t objectStoreId, const String& name, const IDBKeyPath& keyPath, bool isUnique, bool isMultiEntry, int64_t& indexId) OVERRIDE { return false; }
+ virtual bool createIndex(Transaction*, int64_t databaseId, int64_t objectStoreId, int64_t indexId, const String& name, const IDBKeyPath&, bool isUnique, bool isMultiEntry) OVERRIDE { return false; };
virtual void deleteIndex(Transaction*, int64_t databaseId, int64_t objectStoreId, int64_t indexId) OVERRIDE { }
virtual bool putIndexDataForRecord(Transaction*, int64_t databaseId, int64_t objectStoreId, int64_t indexId, const IDBKey&, const ObjectStoreRecordIdentifier*) OVERRIDE { return false; }
virtual bool deleteIndexDataForRecord(Transaction*, int64_t databaseId, int64_t objectStoreId, int64_t indexId, const ObjectStoreRecordIdentifier*) OVERRIDE { return false; }
diff --git a/Source/WebKit/chromium/tests/IDBRequestTest.cpp b/Source/WebKit/chromium/tests/IDBRequestTest.cpp
index 9e2459d39..52a038d5b 100644
--- a/Source/WebKit/chromium/tests/IDBRequestTest.cpp
+++ b/Source/WebKit/chromium/tests/IDBRequestTest.cpp
@@ -58,6 +58,21 @@ TEST(IDBRequestTest, EventsAfterStopping)
request->onSuccess(IDBKey::createInvalid(), IDBKey::createInvalid(), SerializedScriptValue::nullValue());
}
+TEST(IDBRequestTest, AbortErrorAfterAbort)
+{
+ ScriptExecutionContext* context = 0;
+ IDBTransaction* transaction = 0;
+ RefPtr<IDBRequest> request = IDBRequest::create(context, IDBAny::createInvalid(), transaction);
+ EXPECT_EQ(request->readyState(), "pending");
+
+ // Simulate the IDBTransaction having received onAbort from back end and aborting the request:
+ request->abort();
+
+ // Now simulate the back end having fired an abort error at the request to clear up any intermediaries.
+ // Ensure an assertion is not raised.
+ request->onError(IDBDatabaseError::create(IDBDatabaseException::IDB_ABORT_ERR, "Description goes here."));
+}
+
} // namespace
#endif // ENABLE(INDEXED_DATABASE)
diff --git a/Source/WebKit/chromium/tests/ImageLayerChromiumTest.cpp b/Source/WebKit/chromium/tests/ImageLayerChromiumTest.cpp
index 55212e5e8..bfb03ed30 100644
--- a/Source/WebKit/chromium/tests/ImageLayerChromiumTest.cpp
+++ b/Source/WebKit/chromium/tests/ImageLayerChromiumTest.cpp
@@ -38,7 +38,7 @@ namespace {
class MockGraphicsLayerClient : public GraphicsLayerClient {
public:
virtual void notifyAnimationStarted(const GraphicsLayer*, double time) { }
- virtual void notifySyncRequired(const GraphicsLayer*) { }
+ virtual void notifyFlushRequired(const GraphicsLayer*) { }
virtual void paintContents(const GraphicsLayer*, GraphicsContext&, GraphicsLayerPaintingPhase, const IntRect& inClip) { }
virtual bool showDebugBorders(const GraphicsLayer*) const { return false; }
virtual bool showRepaintCounter(const GraphicsLayer*) const { return false; }
diff --git a/Source/WebKit/chromium/tests/LocaleMacTest.cpp b/Source/WebKit/chromium/tests/LocaleMacTest.cpp
index afcd0b889..449776195 100644
--- a/Source/WebKit/chromium/tests/LocaleMacTest.cpp
+++ b/Source/WebKit/chromium/tests/LocaleMacTest.cpp
@@ -57,6 +57,13 @@ protected:
return date;
}
+ DateComponents timeComponents(int hour, int minute, int second, int millisecond)
+ {
+ DateComponents date;
+ date.setMillisecondsSinceMidnight(hour * msPerHour + minute * msPerMinute + second * msPerSecond + millisecond);
+ return date;
+ }
+
double msForDate(int year, int month, int day)
{
return dateToDaysFrom1970(year, month, day) * msPerDay;
@@ -65,13 +72,19 @@ protected:
String formatDate(const String& localeString, int year, int month, int day)
{
OwnPtr<LocaleMac> locale = LocaleMac::create(localeString);
- return locale->formatDate(dateComponents(year, month, day));
+ return locale->formatDateTime(dateComponents(year, month, day));
+ }
+
+ String formatTime(const String& localeString, int hour, int minute, int second, int millisecond, bool useShortFormat)
+ {
+ OwnPtr<LocaleMac> locale = LocaleMac::create(localeString);
+ return locale->formatDateTime(timeComponents(hour, minute, second, millisecond), (useShortFormat ? Localizer::FormatTypeShort : Localizer::FormatTypeMedium));
}
double parseDate(const String& localeString, const String& dateString)
{
OwnPtr<LocaleMac> locale = LocaleMac::create(localeString);
- return locale->parseDate(dateString);
+ return locale->parseDateTime(dateString, DateComponents::Date);
}
#if ENABLE(CALENDAR_PICKER)
@@ -98,9 +111,15 @@ protected:
OwnPtr<LocaleMac> locale = LocaleMac::create(localeString);
return locale->weekDayShortLabels()[index];
}
+
+ bool isRTL(const String& localeString)
+ {
+ OwnPtr<LocaleMac> locale = LocaleMac::create(localeString);
+ return locale->isRTL();
+ }
#endif
-#if ENABLE(INPUT_TYPE_TIME_MULTIPLE_FIELDS)
+#if ENABLE(INPUT_MULTIPLE_FIELDS_UI)
String timeFormat(const String& localeString)
{
OwnPtr<LocaleMac> locale = LocaleMac::create(localeString);
@@ -129,9 +148,30 @@ protected:
TEST_F(LocaleMacTest, formatDate)
{
- EXPECT_STREQ("4/27/05", formatDate("en_US", 2005, April, 27).utf8().data());
- EXPECT_STREQ("27/04/05", formatDate("fr_FR", 2005, April, 27).utf8().data());
- EXPECT_STREQ("05/04/27", formatDate("ja_JP", 2005, April, 27).utf8().data());
+ EXPECT_STREQ("04/27/2005", formatDate("en_US", 2005, April, 27).utf8().data());
+ EXPECT_STREQ("27/04/2005", formatDate("fr_FR", 2005, April, 27).utf8().data());
+ // Do not test ja_JP locale. OS X 10.8 and 10.7 have different formats.
+}
+
+TEST_F(LocaleMacTest, formatTime)
+{
+ EXPECT_STREQ("1:23 PM", formatTime("en_US", 13, 23, 00, 000, true).utf8().data());
+ EXPECT_STREQ("13:23", formatTime("fr_FR", 13, 23, 00, 000, true).utf8().data());
+ EXPECT_STREQ("13:23", formatTime("ja_JP", 13, 23, 00, 000, true).utf8().data());
+ EXPECT_STREQ("\xD9\xA1:\xD9\xA2\xD9\xA3 \xD9\x85", formatTime("ar", 13, 23, 00, 000, true).utf8().data());
+ EXPECT_STREQ("\xDB\xB1\xDB\xB3:\xDB\xB2\xDB\xB3", formatTime("fa", 13, 23, 00, 000, true).utf8().data());
+
+ EXPECT_STREQ("12:00 AM", formatTime("en_US", 00, 00, 00, 000, true).utf8().data());
+ EXPECT_STREQ("00:00", formatTime("fr_FR", 00, 00, 00, 000, true).utf8().data());
+ EXPECT_STREQ("0:00", formatTime("ja_JP", 00, 00, 00, 000, true).utf8().data());
+ EXPECT_STREQ("\xD9\xA1\xD9\xA2:\xD9\xA0\xD9\xA0 \xD8\xB5", formatTime("ar", 00, 00, 00, 000, true).utf8().data());
+ EXPECT_STREQ("\xDB\xB0:\xDB\xB0\xDB\xB0", formatTime("fa", 00, 00, 00, 000, true).utf8().data());
+
+ EXPECT_STREQ("7:07:07.007 AM", formatTime("en_US", 07, 07, 07, 007, false).utf8().data());
+ EXPECT_STREQ("07:07:07,007", formatTime("fr_FR", 07, 07, 07, 007, false).utf8().data());
+ EXPECT_STREQ("7:07:07.007", formatTime("ja_JP", 07, 07, 07, 007, false).utf8().data());
+ EXPECT_STREQ("\xD9\xA7:\xD9\xA0\xD9\xA7:\xD9\xA0\xD9\xA7\xD9\xAB\xD9\xA0\xD9\xA0\xD9\xA7 \xD8\xB5", formatTime("ar", 07, 07, 07, 007, false).utf8().data());
+ EXPECT_STREQ("\xDB\xB7:\xDB\xB0\xDB\xB7:\xDB\xB0\xDB\xB7\xD9\xAB\xDB\xB0\xDB\xB0\xDB\xB7", formatTime("fa", 07, 07, 07, 007, false).utf8().data());
}
TEST_F(LocaleMacTest, parseDate)
@@ -185,9 +225,17 @@ TEST_F(LocaleMacTest, weekDayShortLabels)
EXPECT_STREQ("\xE6\xB0\xB4", weekDayShortLabel("ja_JP", Wednesday).utf8().data());
EXPECT_STREQ("\xE5\x9C\x9F", weekDayShortLabel("ja_JP", Saturday).utf8().data());
}
+
+TEST_F(LocaleMacTest, isRTL)
+{
+ EXPECT_TRUE(isRTL("ar-eg"));
+ EXPECT_FALSE(isRTL("en-us"));
+ EXPECT_FALSE(isRTL("ja-jp"));
+ EXPECT_FALSE(isRTL("**invalid**"));
+}
#endif
-#if ENABLE(INPUT_TYPE_TIME_MULTIPLE_FIELDS)
+#if ENABLE(INPUT_MULTIPLE_FIELDS_UI)
TEST_F(LocaleMacTest, timeFormat)
{
EXPECT_STREQ("h:mm:ss a", timeFormat("en_US").utf8().data());
diff --git a/Source/WebKit/chromium/tests/LocaleWinTest.cpp b/Source/WebKit/chromium/tests/LocaleWinTest.cpp
index a3719f0d3..75af419dd 100644
--- a/Source/WebKit/chromium/tests/LocaleWinTest.cpp
+++ b/Source/WebKit/chromium/tests/LocaleWinTest.cpp
@@ -87,13 +87,13 @@ protected:
String formatDate(LCID lcid, int year, int month, int day)
{
OwnPtr<LocaleWin> locale = LocaleWin::create(lcid);
- return locale->formatDate(dateComponents(year, month, day));
+ return locale->formatDateTime(dateComponents(year, month, day));
}
double parseDate(LCID lcid, const String& dateString)
{
OwnPtr<LocaleWin> locale = LocaleWin::create(lcid);
- return locale->parseDate(dateString);
+ return locale->parseDateTime(dateString, DateComponents::Date);
}
#if ENABLE(CALENDAR_PICKER)
@@ -120,9 +120,15 @@ protected:
OwnPtr<LocaleWin> locale = LocaleWin::create(lcid);
return locale->weekDayShortLabels()[index];
}
+
+ bool isRTL(LCID lcid)
+ {
+ OwnPtr<LocaleWin> locale = LocaleWin::create(lcid);
+ return locale->isRTL();
+ }
#endif
-#if ENABLE(INPUT_TYPE_TIME_MULTIPLE_FIELDS)
+#if ENABLE(INPUT_MULTIPLE_FIELDS_UI)
String timeFormat(LCID lcid)
{
OwnPtr<LocaleWin> locale = LocaleWin::create(lcid);
@@ -163,68 +169,6 @@ TEST_F(LocaleWinTest, TestLocalizedDateFormatText)
EXPECT_STREQ("YY/mm/DD", LocaleWin::dateFormatText("YY/mm/DD", "year", "month", "day").utf8().data());
}
-TEST_F(LocaleWinTest, TestFormat)
-{
- OwnPtr<LocaleWin> locale = LocaleWin::create(EnglishUS);
-
- EXPECT_STREQ("4/7/2", locale->formatDate("M/d/y", 2012, 2012, April, 7).utf8().data());
- EXPECT_STREQ("4/7/2007", locale->formatDate("M/d/y", 2012, 2007, April, 7).utf8().data());
- EXPECT_STREQ("4/7/8", locale->formatDate("M/d/y", 2012, 2008, April, 7).utf8().data());
- EXPECT_STREQ("4/7/7", locale->formatDate("M/d/y", 2012, 2017, April, 7).utf8().data());
- EXPECT_STREQ("4/7/2018", locale->formatDate("M/d/y", 2012, 2018, April, 7).utf8().data());
- EXPECT_STREQ("12/31/2062", locale->formatDate("M/d/y", 2012, 2062, December, 31).utf8().data());
- EXPECT_STREQ("4/7/0002", locale->formatDate("M/d/y", 2012, 2, April, 7).utf8().data());
-
- EXPECT_STREQ("04/27/12", locale->formatDate("MM/dd/yy", 2012, 2012, April, 27).utf8().data());
- EXPECT_STREQ("04/07/1962", locale->formatDate("MM/dd/yy", 2012, 1962, April, 7).utf8().data());
- EXPECT_STREQ("04/07/63", locale->formatDate("MM/dd/yy", 2012, 1963, April, 7).utf8().data());
- EXPECT_STREQ("01/31/00", locale->formatDate("MM/dd/yy", 2012, 2000, January, 31).utf8().data());
- EXPECT_STREQ("04/07/62", locale->formatDate("MM/dd/yy", 2012, 2062, April, 7).utf8().data());
- EXPECT_STREQ("04/07/2063", locale->formatDate("MM/dd/yy", 2012, 2063, April, 7).utf8().data());
- EXPECT_STREQ("04/07/0001", locale->formatDate("MM/dd/yy", 2012, 1, April, 7).utf8().data());
-
- EXPECT_STREQ("Jan/7/2012", locale->formatDate("MMM/d/yyyy", 2012, 2012, January, 7).utf8().data());
- EXPECT_STREQ("Feb/7/2008", locale->formatDate("MMM/d/yyyy", 2012, 2008, February, 7).utf8().data());
- EXPECT_STREQ("Mar/7/2017", locale->formatDate("MMM/d/yyyy", 2012, 2017, March, 7).utf8().data());
- EXPECT_STREQ("Apr/7/2012", locale->formatDate("MMM/d/yyyy", 2012, 2012, April, 7).utf8().data());
- EXPECT_STREQ("May/7/0002", locale->formatDate("MMM/d/yyyy", 2012, 2, May, 7).utf8().data());
- EXPECT_STREQ("Jun/7/2008", locale->formatDate("MMM/d/yyyy", 2012, 2008, June, 7).utf8().data());
- EXPECT_STREQ("Jul/7/2017", locale->formatDate("MMM/d/yyyy", 2012, 2017, July, 7).utf8().data());
- EXPECT_STREQ("Aug/31/2062", locale->formatDate("MMM/d/yyyy", 2012, 2062, August, 31).utf8().data());
- EXPECT_STREQ("Sep/7/0002", locale->formatDate("MMM/d/yyyy", 2012, 2, September, 7).utf8().data());
- EXPECT_STREQ("Oct/7/2012", locale->formatDate("MMM/d/yyyy", 2012, 2012, October, 7).utf8().data());
- EXPECT_STREQ("Nov/7/2008", locale->formatDate("MMM/d/yyyy", 2012, 2008, November, 7).utf8().data());
- EXPECT_STREQ("Dec/31/2062", locale->formatDate("MMM/d/yyyy", 2012, 2062, December, 31).utf8().data());
-
- EXPECT_STREQ("January-7-2017", locale->formatDate("MMMM-d-yyyy", 2012, 2017, January, 7).utf8().data());
- EXPECT_STREQ("February-31-2062", locale->formatDate("MMMM-d-yyyy", 2012, 2062, February, 31).utf8().data());
- EXPECT_STREQ("March-7-0002", locale->formatDate("MMMM-d-yyyy", 2012, 2, March, 7).utf8().data());
- EXPECT_STREQ("April-7-22012", locale->formatDate("MMMM-d-yyyy", 2012, 22012, April, 7).utf8().data());
- EXPECT_STREQ("May-7-12008", locale->formatDate("MMMM-d-yyyy", 2012, 12008, May, 7).utf8().data());
- EXPECT_STREQ("June-7-22012", locale->formatDate("MMMM-d-yyyy", 2012, 22012, June, 7).utf8().data());
- EXPECT_STREQ("July-7-12008", locale->formatDate("MMMM-d-yyyy", 2012, 12008, July, 7).utf8().data());
- EXPECT_STREQ("August-7-2017", locale->formatDate("MMMM-d-yyyy", 2012, 2017, August, 7).utf8().data());
- EXPECT_STREQ("September-31-2062", locale->formatDate("MMMM-d-yyyy", 2012, 2062, September, 31).utf8().data());
- EXPECT_STREQ("October-7-0002", locale->formatDate("MMMM-d-yyyy", 2012, 2, October, 7).utf8().data());
- EXPECT_STREQ("November-7-22012", locale->formatDate("MMMM-d-yyyy", 2012, 22012, November, 7).utf8().data());
- EXPECT_STREQ("December-7-12008", locale->formatDate("MMMM-d-yyyy", 2012, 12008, December, 7).utf8().data());
-
- EXPECT_STREQ("Jan-1-0001", locale->formatDate("MMM-d-yyyy", 2012, 1, January, 1).utf8().data());
- EXPECT_STREQ("Sep-13-275760", locale->formatDate("MMM-d-yyyy", 2012, 275760, September, 13).utf8().data());
-
- OwnPtr<LocaleWin> persian = LocaleWin::create(Persian);
- // U+06F0 U+06F1 / U+06F0 U+06F8 / U+06F0 U+06F0 U+06F0 U+06F2
- EXPECT_STREQ("\xDB\xB0\xDB\xB1/\xDB\xB0\xDB\xB8/\xDB\xB0\xDB\xB0\xDB\xB0\xDB\xB1", persian->formatDate("dd/MM/yyyy", 2012, 1, August, 1).utf8().data());
-
- // For the following test, we'd like to confirm they don't crash and their
- // results are not important because we can assume invalid arguments are
- // never passed.
- EXPECT_STREQ("2012-13-00", locale->formatDate("yyyy-MM-dd", -1, 2012, December + 1, 0).utf8().data());
- EXPECT_STREQ("-1-00--1", locale->formatDate("y-MM-dd", -1, -1, -1, -1).utf8().data());
- EXPECT_STREQ("-1-124-33", locale->formatDate("y-MM-dd", 2012, -1, 123, 33).utf8().data());
-
-}
-
TEST_F(LocaleWinTest, TestParse)
{
OwnPtr<LocaleWin> locale = LocaleWin::create(EnglishUS);
@@ -266,7 +210,7 @@ TEST_F(LocaleWinTest, TestParse)
TEST_F(LocaleWinTest, formatDate)
{
- EXPECT_STREQ("4/27/2005", formatDate(EnglishUS, 2005, April, 27).utf8().data());
+ EXPECT_STREQ("04/27/2005", formatDate(EnglishUS, 2005, April, 27).utf8().data());
EXPECT_STREQ("27/04/2005", formatDate(FrenchFR, 2005, April, 27).utf8().data());
EXPECT_STREQ("2005/04/27", formatDate(JapaneseJP, 2005, April, 27).utf8().data());
}
@@ -322,9 +266,24 @@ TEST_F(LocaleWinTest, weekDayShortLabels)
EXPECT_STREQ("\xE6\xB0\xB4", weekDayShortLabel(JapaneseJP, Wednesday).utf8().data());
EXPECT_STREQ("\xE5\x9C\x9F", weekDayShortLabel(JapaneseJP, Saturday).utf8().data());
}
+
+TEST_F(LocaleWinTest, isRTL)
+{
+ EXPECT_TRUE(isRTL(ArabicEG));
+ EXPECT_FALSE(isRTL(EnglishUS));
+}
+
#endif
-#if ENABLE(INPUT_TYPE_TIME_MULTIPLE_FIELDS)
+#if ENABLE(INPUT_MULTIPLE_FIELDS_UI)
+TEST_F(LocaleWinTest, dateFormat)
+{
+ EXPECT_STREQ("y'-'M'-'d", LocaleWin::dateFormat("y-M-d").utf8().data());
+ EXPECT_STREQ("''yy'-'''MM'''-'dd", LocaleWin::dateFormat("''yy-''MM''-dd").utf8().data());
+ EXPECT_STREQ("yyyy'-''''-'MMM'''''-'dd", LocaleWin::dateFormat("yyyy-''''-MMM''''-dd").utf8().data());
+ EXPECT_STREQ("yyyy'-'''''MMMM'-'dd", LocaleWin::dateFormat("yyyy-''''MMMM-dd").utf8().data());
+}
+
TEST_F(LocaleWinTest, timeFormat)
{
EXPECT_STREQ("h:mm:ss a", timeFormat(EnglishUS).utf8().data());
diff --git a/Source/WebKit/chromium/tests/LocalizedDateICUTest.cpp b/Source/WebKit/chromium/tests/LocalizedDateICUTest.cpp
index 749f91038..771a3cbc0 100644
--- a/Source/WebKit/chromium/tests/LocalizedDateICUTest.cpp
+++ b/Source/WebKit/chromium/tests/LocalizedDateICUTest.cpp
@@ -30,7 +30,7 @@
#include "config.h"
-#if ENABLE(INPUT_TYPE_TIME_MULTIPLE_FIELDS)
+#if ENABLE(INPUT_MULTIPLE_FIELDS_UI)
#include "LocaleICU.h"
#include <gtest/gtest.h>
@@ -105,6 +105,12 @@ protected:
OwnPtr<LocaleICU> locale = LocaleICU::create(localeString);
return Labels(locale->timeAMPMLabels());
}
+
+ bool isRTL(const char* localeString)
+ {
+ OwnPtr<LocaleICU> locale = LocaleICU::create(localeString);
+ return locale->isRTL();
+ }
};
std::ostream& operator<<(std::ostream& os, const LocalizedDateICUTest::Labels& labels)
@@ -112,6 +118,14 @@ std::ostream& operator<<(std::ostream& os, const LocalizedDateICUTest::Labels& l
return os << labels.toString().utf8().data();
}
+TEST_F(LocalizedDateICUTest, isRTL)
+{
+ EXPECT_TRUE(isRTL("ar-EG"));
+ EXPECT_FALSE(isRTL("en-us"));
+ EXPECT_FALSE(isRTL("ja-jp"));
+ EXPECT_FALSE(isRTL("**invalid**"));
+}
+
TEST_F(LocalizedDateICUTest, localizedDateFormatText)
{
// Note: EXPECT_EQ(String, String) doesn't print result as string.
diff --git a/Source/WebKit/chromium/tests/LocalizedNumberICUTest.cpp b/Source/WebKit/chromium/tests/LocalizedNumberICUTest.cpp
index ec7de4e9e..6facdc1a1 100644
--- a/Source/WebKit/chromium/tests/LocalizedNumberICUTest.cpp
+++ b/Source/WebKit/chromium/tests/LocalizedNumberICUTest.cpp
@@ -80,7 +80,7 @@ TEST(LocalizedNumberICUTest, Reversible)
testNumbers("zh_TW");
}
-#if ENABLE(INPUT_TYPE_TIME_MULTIPLE_FIELDS)
+#if ENABLE(INPUT_MULTIPLE_FIELDS_UI)
static String testDecimalSeparator(const AtomicString& locale)
{
diff --git a/Source/WebKit/chromium/tests/MemoryInstrumentationTest.cpp b/Source/WebKit/chromium/tests/MemoryInstrumentationTest.cpp
deleted file mode 100644
index 21ce96316..000000000
--- a/Source/WebKit/chromium/tests/MemoryInstrumentationTest.cpp
+++ /dev/null
@@ -1,443 +0,0 @@
-/*
- * 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:
- *
- * * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * * 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.
- * * Neither the name of Google Inc. 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 THE COPYRIGHT HOLDERS AND 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 THE COPYRIGHT
- * OWNER 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 "DataRef.h"
-#include "MemoryInstrumentationImpl.h"
-#include "WebCoreMemoryInstrumentation.h"
-
-#include <gtest/gtest.h>
-
-#include <wtf/HashSet.h>
-#include <wtf/MemoryInstrumentationVector.h>
-#include <wtf/RefCounted.h>
-#include <wtf/Vector.h>
-#include <wtf/text/AtomicString.h>
-#include <wtf/text/CString.h>
-#include <wtf/text/StringImpl.h>
-#include <wtf/text/WTFString.h>
-
-using namespace WebCore;
-
-namespace {
-
-class NotInstrumented {
-public:
- NotInstrumented(const char* = 0) { }
- char m_data[42];
-};
-
-class Instrumented {
-public:
- Instrumented() : m_notInstrumented(new NotInstrumented) { }
- virtual ~Instrumented() { delete m_notInstrumented; }
-
- virtual void reportMemoryUsage(MemoryObjectInfo* memoryObjectInfo) const
- {
- MemoryClassInfo info(memoryObjectInfo, this, WebCoreMemoryTypes::DOM);
- info.addMember(m_notInstrumented);
- }
- NotInstrumented* m_notInstrumented;
-};
-
-TEST(MemoryInstrumentationTest, sizeOf)
-{
- VisitedObjects visitedObjects;
- MemoryInstrumentationImpl impl(visitedObjects);
- Instrumented instrumented;
- impl.addRootObject(instrumented);
- EXPECT_EQ(sizeof(NotInstrumented), impl.reportedSizeForAllTypes());
- EXPECT_EQ(1, visitedObjects.size());
-}
-
-TEST(MemoryInstrumentationTest, nullCheck)
-{
- VisitedObjects visitedObjects;
- MemoryInstrumentationImpl impl(visitedObjects);
- Instrumented* instrumented = 0;
- impl.addRootObject(instrumented);
- EXPECT_EQ(0u, impl.reportedSizeForAllTypes());
- EXPECT_EQ(0, visitedObjects.size());
-}
-
-TEST(MemoryInstrumentationTest, ptrVsRef)
-{
- {
- VisitedObjects visitedObjects;
- MemoryInstrumentationImpl impl(visitedObjects);
- Instrumented instrumented;
- impl.addRootObject(&instrumented);
- EXPECT_EQ(sizeof(Instrumented) + sizeof(NotInstrumented), impl.reportedSizeForAllTypes());
- EXPECT_EQ(2, visitedObjects.size());
- }
- {
- VisitedObjects visitedObjects;
- MemoryInstrumentationImpl impl(visitedObjects);
- Instrumented instrumented;
- impl.addRootObject(instrumented);
- EXPECT_EQ(sizeof(NotInstrumented), impl.reportedSizeForAllTypes());
- EXPECT_EQ(1, visitedObjects.size());
- }
-}
-
-TEST(MemoryInstrumentationTest, ownPtr)
-{
- VisitedObjects visitedObjects;
- MemoryInstrumentationImpl impl(visitedObjects);
- OwnPtr<Instrumented> instrumented(adoptPtr(new Instrumented));
- impl.addRootObject(instrumented);
- EXPECT_EQ(sizeof(Instrumented) + sizeof(NotInstrumented), impl.reportedSizeForAllTypes());
- EXPECT_EQ(2, visitedObjects.size());
-}
-
-class InstrumentedRefPtr : public RefCounted<InstrumentedRefPtr> {
-public:
- InstrumentedRefPtr() : m_notInstrumented(new NotInstrumented) { }
- virtual ~InstrumentedRefPtr() { delete m_notInstrumented; }
- static PassRefPtr<InstrumentedRefPtr> create() { return adoptRef(new InstrumentedRefPtr()); }
-
- virtual void reportMemoryUsage(MemoryObjectInfo* memoryObjectInfo) const
- {
- MemoryClassInfo info(memoryObjectInfo, this, WebCoreMemoryTypes::DOM);
- info.addMember(m_notInstrumented);
- }
- NotInstrumented* m_notInstrumented;
-};
-
-TEST(MemoryInstrumentationTest, dataRef)
-{
- VisitedObjects visitedObjects;
- MemoryInstrumentationImpl impl(visitedObjects);
- DataRef<InstrumentedRefPtr> instrumentedRefPtr;
- instrumentedRefPtr.init();
- impl.addRootObject(instrumentedRefPtr);
- EXPECT_EQ(sizeof(InstrumentedRefPtr) + sizeof(NotInstrumented), impl.reportedSizeForAllTypes());
- EXPECT_EQ(2, visitedObjects.size());
-}
-
-TEST(MemoryInstrumentationTest, refPtr)
-{
- VisitedObjects visitedObjects;
- MemoryInstrumentationImpl impl(visitedObjects);
- RefPtr<InstrumentedRefPtr> instrumentedRefPtr(adoptRef(new InstrumentedRefPtr));
- impl.addRootObject(instrumentedRefPtr);
- EXPECT_EQ(sizeof(InstrumentedRefPtr) + sizeof(NotInstrumented), impl.reportedSizeForAllTypes());
- EXPECT_EQ(2, visitedObjects.size());
-}
-
-class InstrumentedWithOwnPtr : public Instrumented {
-public:
- InstrumentedWithOwnPtr() : m_notInstrumentedOwnPtr(adoptPtr(new NotInstrumented)) { }
-
- virtual void reportMemoryUsage(MemoryObjectInfo* memoryObjectInfo) const
- {
- MemoryClassInfo info(memoryObjectInfo, this, WebCoreMemoryTypes::CSS);
- Instrumented::reportMemoryUsage(memoryObjectInfo);
- info.addMember(m_notInstrumentedOwnPtr);
- }
- OwnPtr<NotInstrumented> m_notInstrumentedOwnPtr;
-};
-
-TEST(MemoryInstrumentationTest, ownPtrNotInstrumented)
-{
- VisitedObjects visitedObjects;
- MemoryInstrumentationImpl impl(visitedObjects);
- InstrumentedWithOwnPtr instrumentedWithOwnPtr;
- impl.addRootObject(instrumentedWithOwnPtr);
- EXPECT_EQ(2 * sizeof(NotInstrumented), impl.reportedSizeForAllTypes());
- EXPECT_EQ(2, visitedObjects.size());
-}
-
-class InstrumentedUndefined {
-public:
- InstrumentedUndefined() : m_data(0) { }
-
- void reportMemoryUsage(MemoryObjectInfo* memoryObjectInfo) const
- {
- MemoryClassInfo info(memoryObjectInfo, this);
- }
- int m_data;
-};
-
-class InstrumentedDOM {
-public:
- InstrumentedDOM() : m_instrumentedUndefined(adoptPtr(new InstrumentedUndefined)) { }
-
- void reportMemoryUsage(MemoryObjectInfo* memoryObjectInfo) const
- {
- MemoryClassInfo info(memoryObjectInfo, this, WebCoreMemoryTypes::DOM);
- info.addMember(m_instrumentedUndefined);
- }
- OwnPtr<InstrumentedUndefined> m_instrumentedUndefined;
-};
-
-TEST(MemoryInstrumentationTest, ownerTypePropagation)
-{
- VisitedObjects visitedObjects;
- MemoryInstrumentationImpl impl(visitedObjects);
- OwnPtr<InstrumentedDOM> instrumentedDOM(adoptPtr(new InstrumentedDOM));
- impl.addRootObject(instrumentedDOM);
- EXPECT_EQ(sizeof(InstrumentedDOM) + sizeof(InstrumentedUndefined), impl.reportedSizeForAllTypes());
- EXPECT_EQ(sizeof(InstrumentedDOM) + sizeof(InstrumentedUndefined), impl.totalSize(WebCoreMemoryTypes::DOM));
- EXPECT_EQ(2, visitedObjects.size());
-}
-
-class NonVirtualInstrumented {
-public:
- void reportMemoryUsage(MemoryObjectInfo* memoryObjectInfo) const
- {
- MemoryClassInfo info(memoryObjectInfo, this, WebCoreMemoryTypes::DOM);
- info.addMember(m_instrumented);
- }
-
- Instrumented m_instrumented;
-};
-
-TEST(MemoryInstrumentationTest, visitFirstMemberInNonVirtualClass)
-{
- VisitedObjects visitedObjects;
- MemoryInstrumentationImpl impl(visitedObjects);
- NonVirtualInstrumented nonVirtualInstrumented;
- impl.addRootObject(&nonVirtualInstrumented);
- EXPECT_EQ(sizeof(NonVirtualInstrumented) + sizeof(NotInstrumented), impl.reportedSizeForAllTypes());
- EXPECT_EQ(2, visitedObjects.size());
-}
-
-template<typename T>
-class InstrumentedOwner {
-public:
- template<typename V>
- InstrumentedOwner(const V& value) : m_value(value) { }
- InstrumentedOwner() { }
- void reportMemoryUsage(MemoryObjectInfo* memoryObjectInfo) const
- {
- MemoryClassInfo info(memoryObjectInfo, this, WebCoreMemoryTypes::DOM);
- info.addMember(m_value);
- }
-
- T m_value;
-};
-
-TEST(MemoryInstrumentationTest, visitStrings)
-{
- {
- VisitedObjects visitedObjects;
- MemoryInstrumentationImpl impl(visitedObjects);
- InstrumentedOwner<String> stringInstrumentedOwner("String");
- stringInstrumentedOwner.m_value.characters(); // Force 16bit shadow creation.
- impl.addRootObject(stringInstrumentedOwner);
- EXPECT_EQ(sizeof(StringImpl) + stringInstrumentedOwner.m_value.length() * 2, impl.reportedSizeForAllTypes());
- EXPECT_EQ(2, visitedObjects.size());
- }
-
- {
- VisitedObjects visitedObjects;
- MemoryInstrumentationImpl impl(visitedObjects);
- InstrumentedOwner<AtomicString> atomicStringInstrumentedOwner("AtomicString");
- atomicStringInstrumentedOwner.m_value.string().characters(); // Force 16bit shadow creation.
- impl.addRootObject(atomicStringInstrumentedOwner);
- EXPECT_EQ(sizeof(StringImpl) + atomicStringInstrumentedOwner.m_value.length() * 2, impl.reportedSizeForAllTypes());
- EXPECT_EQ(2, visitedObjects.size());
- }
-
- {
- VisitedObjects visitedObjects;
- MemoryInstrumentationImpl impl(visitedObjects);
- InstrumentedOwner<CString> cStringInstrumentedOwner("CString");
- impl.addRootObject(cStringInstrumentedOwner);
- EXPECT_EQ(sizeof(WTF::CStringBuffer) + cStringInstrumentedOwner.m_value.length(), impl.reportedSizeForAllTypes());
- EXPECT_EQ(1, visitedObjects.size());
- }
-}
-
-class TwoPointersToRefPtr {
-public:
- TwoPointersToRefPtr(const RefPtr<StringImpl>& value) : m_ptr1(&value), m_ptr2(&value) { }
- void reportMemoryUsage(MemoryObjectInfo* memoryObjectInfo) const
- {
- MemoryClassInfo info(memoryObjectInfo, this, WebCoreMemoryTypes::DOM);
- info.addMember(m_ptr1);
- info.addMember(m_ptr2);
- }
-
- const RefPtr<StringImpl>* m_ptr1;
- const RefPtr<StringImpl>* m_ptr2;
-};
-
-TEST(MemoryInstrumentationTest, refPtrPtr)
-{
- RefPtr<StringImpl> refPtr;
- TwoPointersToRefPtr root(refPtr);
- VisitedObjects visitedObjects;
- MemoryInstrumentationImpl impl(visitedObjects);
- impl.addRootObject(root);
- EXPECT_EQ(sizeof(RefPtr<StringImpl>), impl.reportedSizeForAllTypes());
- EXPECT_EQ(1, visitedObjects.size());
-}
-
-class TwoPointersToOwnPtr {
-public:
- TwoPointersToOwnPtr(const OwnPtr<NotInstrumented>& value) : m_ptr1(&value), m_ptr2(&value) { }
- void reportMemoryUsage(MemoryObjectInfo* memoryObjectInfo) const
- {
- MemoryClassInfo info(memoryObjectInfo, this, WebCoreMemoryTypes::DOM);
- info.addMember(m_ptr1);
- info.addMember(m_ptr2);
- }
-
- const OwnPtr<NotInstrumented>* m_ptr1;
- const OwnPtr<NotInstrumented>* m_ptr2;
-};
-
-TEST(MemoryInstrumentationTest, ownPtrPtr)
-{
- OwnPtr<NotInstrumented> ownPtr;
- TwoPointersToOwnPtr root(ownPtr);
- VisitedObjects visitedObjects;
- MemoryInstrumentationImpl impl(visitedObjects);
- impl.addRootObject(root);
- EXPECT_EQ(sizeof(OwnPtr<NotInstrumented>), impl.reportedSizeForAllTypes());
- EXPECT_EQ(1, visitedObjects.size());
-}
-
-template<typename T>
-class InstrumentedTemplate {
-public:
- template<typename V>
- InstrumentedTemplate(const V& value) : m_value(value) { }
-
- template<typename MemoryObjectInfo>
- void reportMemoryUsage(MemoryObjectInfo* memoryObjectInfo) const
- {
- typename MemoryObjectInfo::ClassInfo info(memoryObjectInfo, this, WebCoreMemoryTypes::DOM);
- info.addMember(m_value);
- }
-
- T m_value;
-};
-
-TEST(MemoryInstrumentationTest, detectReportMemoryUsageMethod)
-{
- {
- VisitedObjects visitedObjects;
- MemoryInstrumentationImpl impl(visitedObjects);
-
- OwnPtr<InstrumentedTemplate<String> > value = adoptPtr(new InstrumentedTemplate<String>(""));
- InstrumentedOwner<InstrumentedTemplate<String>* > root(value.get());
- impl.addRootObject(root);
- EXPECT_EQ(sizeof(InstrumentedTemplate<String>) + sizeof(StringImpl), impl.reportedSizeForAllTypes());
- // FIXME: it is failing on Chromium Canary bots but works fine locally.
- // EXPECT_EQ(2, visitedObjects.size());
- }
- {
- VisitedObjects visitedObjects;
- MemoryInstrumentationImpl impl(visitedObjects);
-
- OwnPtr<InstrumentedTemplate<NotInstrumented> > value = adoptPtr(new InstrumentedTemplate<NotInstrumented>(""));
- InstrumentedOwner<InstrumentedTemplate<NotInstrumented>* > root(value.get());
- impl.addRootObject(root);
- EXPECT_EQ(sizeof(InstrumentedTemplate<NotInstrumented>), impl.reportedSizeForAllTypes());
- EXPECT_EQ(1, visitedObjects.size());
- }
-}
-
-TEST(MemoryInstrumentationTest, vectorZeroInlineCapacity)
-{
- VisitedObjects visitedObjects;
- MemoryInstrumentationImpl impl(visitedObjects);
- InstrumentedOwner<Vector<int> > vectorOwner(16);
- impl.addRootObject(vectorOwner);
- EXPECT_EQ(16 * sizeof(int), impl.reportedSizeForAllTypes());
- EXPECT_EQ(1, visitedObjects.size());
-}
-
-TEST(MemoryInstrumentationTest, vectorFieldWithInlineCapacity)
-{
- VisitedObjects visitedObjects;
- MemoryInstrumentationImpl impl(visitedObjects);
- InstrumentedOwner<Vector<int, 4> > vectorOwner;
- impl.addRootObject(vectorOwner);
- EXPECT_EQ(static_cast<size_t>(0), impl.reportedSizeForAllTypes());
- EXPECT_EQ(0, visitedObjects.size());
-}
-
-TEST(MemoryInstrumentationTest, vectorFieldWithInlineCapacityResized)
-{
- VisitedObjects visitedObjects;
- MemoryInstrumentationImpl impl(visitedObjects);
- InstrumentedOwner<Vector<int, 4> > vectorOwner;
- vectorOwner.m_value.reserveCapacity(8);
- impl.addRootObject(vectorOwner);
- EXPECT_EQ(8 * sizeof(int), impl.reportedSizeForAllTypes());
- EXPECT_EQ(1, visitedObjects.size());
-}
-
-TEST(MemoryInstrumentationTest, heapAllocatedVectorWithInlineCapacity)
-{
- VisitedObjects visitedObjects;
- MemoryInstrumentationImpl impl(visitedObjects);
- InstrumentedOwner<OwnPtr<Vector<int, 4> > > vectorOwner;
- vectorOwner.m_value = adoptPtr(new Vector<int, 4>());
- impl.addRootObject(vectorOwner);
- EXPECT_EQ(sizeof(Vector<int, 4>), impl.reportedSizeForAllTypes());
- EXPECT_EQ(1, visitedObjects.size());
-}
-
-TEST(MemoryInstrumentationTest, heapAllocatedVectorWithInlineCapacityResized)
-{
- VisitedObjects visitedObjects;
- MemoryInstrumentationImpl impl(visitedObjects);
- InstrumentedOwner<OwnPtr<Vector<int, 4> > > vectorOwner;
- vectorOwner.m_value = adoptPtr(new Vector<int, 4>());
- vectorOwner.m_value->reserveCapacity(8);
- impl.addRootObject(vectorOwner);
- EXPECT_EQ(8 * sizeof(int) + sizeof(Vector<int, 4>), impl.reportedSizeForAllTypes());
- EXPECT_EQ(2, visitedObjects.size());
-}
-
-TEST(MemoryInstrumentationTest, vectorWithInstrumentedType)
-{
- VisitedObjects visitedObjects;
- MemoryInstrumentationImpl impl(visitedObjects);
-
- typedef Vector<String> StringVector;
- OwnPtr<StringVector> value = adoptPtr(new StringVector());
- size_t count = 10;
- for (size_t i = 0; i < count; ++i)
- value->append("string");
- InstrumentedOwner<StringVector* > root(value.get());
- impl.addRootObject(root);
- EXPECT_EQ(sizeof(StringVector) + sizeof(String) * value->capacity() + sizeof(StringImpl) * value->size(), impl.reportedSizeForAllTypes());
- EXPECT_EQ(count + 2, (size_t)visitedObjects.size());
-}
-
-} // namespace
-
diff --git a/Source/WebKit/chromium/tests/ScrollingCoordinatorChromiumTest.cpp b/Source/WebKit/chromium/tests/ScrollingCoordinatorChromiumTest.cpp
index b4fa4a1db..d70570114 100644
--- a/Source/WebKit/chromium/tests/ScrollingCoordinatorChromiumTest.cpp
+++ b/Source/WebKit/chromium/tests/ScrollingCoordinatorChromiumTest.cpp
@@ -183,6 +183,15 @@ TEST_F(ScrollingCoordinatorChromiumTest, wheelEventHandler)
ASSERT_TRUE(rootScrollLayer->haveWheelEventHandlers());
}
+TEST_F(ScrollingCoordinatorChromiumTest, clippedBodyTest)
+{
+ registerMockedHttpURLLoad("clipped-body.html");
+ navigateTo(m_baseURL + "clipped-body.html");
+
+ WebLayer* rootScrollLayer = getRootScrollLayer();
+ ASSERT_EQ(0u, rootScrollLayer->nonFastScrollableRegion().size());
+}
+
#if ENABLE(ACCELERATED_OVERFLOW_SCROLLING)
TEST_F(ScrollingCoordinatorChromiumTest, touchOverflowScrolling)
{
diff --git a/Source/WebKit/chromium/tests/WebFrameTest.cpp b/Source/WebKit/chromium/tests/WebFrameTest.cpp
index a0049b67e..d4bc4819e 100644
--- a/Source/WebKit/chromium/tests/WebFrameTest.cpp
+++ b/Source/WebKit/chromium/tests/WebFrameTest.cpp
@@ -316,76 +316,256 @@ TEST_F(WebFrameTest, CanOverrideMaximumScaleFactor)
}
#if ENABLE(GESTURE_EVENTS)
+class DivAutoZoomTestWebViewClient : public WebViewClient {
+ public:
+ virtual WebRect windowRect() OVERRIDE { return m_windowRect; }
+
+ WebRect m_windowRect;
+};
+
+void setScaleAndScrollAndLayout(WebKit::WebView* webView, WebPoint scroll, float scale)
+{
+ webView->setPageScaleFactor(scale, WebPoint(scroll.x, scroll.y));
+ webView->layout();
+}
+
TEST_F(WebFrameTest, DivAutoZoomParamsTest)
{
registerMockedHttpURLLoad("get_scale_for_auto_zoom_into_div_test.html");
- WebViewImpl* webViewImpl = static_cast<WebViewImpl*>(FrameTestHelpers::createWebViewAndLoad(m_baseURL + "get_scale_for_auto_zoom_into_div_test.html", true));
- int pageWidth = 640;
- int pageHeight = 480;
- int divPosX = 200;
- int divPosY = 200;
- int divWidth = 200;
- int divHeight = 150;
- WebRect doubleTapPoint(250, 250, 0, 0);
- webViewImpl->resize(WebSize(pageWidth, pageHeight));
+ DivAutoZoomTestWebViewClient client;
+ int viewportWidth = 640;
+ int viewportHeight = 480;
+ client.m_windowRect = WebRect(0, 0, viewportWidth, viewportHeight);
+ WebKit::WebView* webView = FrameTestHelpers::createWebViewAndLoad(m_baseURL + "get_scale_for_auto_zoom_into_div_test.html", true, 0, &client);
+ webView->enableFixedLayoutMode(true);
+ webView->setDeviceScaleFactor(2.0f);
+ webView->resize(WebSize(viewportWidth, viewportHeight));
+ webView->setPageScaleFactorLimits(0.01f, 4);
+ webView->layout();
+
+ WebRect wideDiv(200, 100, 400, 150);
+ WebRect tallDiv(200, 300, 400, 800);
+ WebRect doubleTapPointWide((wideDiv.x + 50) * webView->pageScaleFactor(),
+ (wideDiv.y + 50) * webView->pageScaleFactor(), 0, 0);
+ WebRect doubleTapPointTall((tallDiv.x + 50) * webView->pageScaleFactor(),
+ (tallDiv.y + 50) * webView->pageScaleFactor(), 0, 0);
float scale;
WebPoint scroll;
+ bool isAnchor;
+
+ WebViewImpl* webViewImpl = static_cast<WebViewImpl*>(webView);
+ // Test double-tap zooming into wide div.
+ webViewImpl->computeScaleAndScrollForHitRect(doubleTapPointWide, WebViewImpl::DoubleTap, scale, scroll, isAnchor);
+ // The div should horizontally fill the screen (modulo margins), and
+ // vertically centered (modulo integer rounding).
+ EXPECT_NEAR(viewportWidth / (float) wideDiv.width, scale, 0.1);
+ EXPECT_NEAR(wideDiv.x * scale, scroll.x, 20);
+ int vScroll = (wideDiv.y + wideDiv.height / 2) * scale - (viewportHeight / 2);
+ EXPECT_NEAR(vScroll, scroll.y, 1);
+ EXPECT_FALSE(isAnchor);
+
+ setScaleAndScrollAndLayout(webViewImpl, scroll, scale);
+
+ // Test zoom out back to minimum scale.
+ webViewImpl->computeScaleAndScrollForHitRect(doubleTapPointWide, WebViewImpl::DoubleTap, scale, scroll, isAnchor);
+ EXPECT_FLOAT_EQ(webViewImpl->minimumPageScaleFactor(), scale);
+ EXPECT_TRUE(isAnchor);
+
+ setScaleAndScrollAndLayout(webViewImpl, WebPoint(0, 0), scale);
+
+ // Test double-tap zooming into tall div.
+ webViewImpl->computeScaleAndScrollForHitRect(doubleTapPointTall, WebViewImpl::DoubleTap, scale, scroll, isAnchor);
+ // The div should start at the top left of the viewport.
+ EXPECT_NEAR(viewportWidth / (float) tallDiv.width, scale, 0.1);
+ EXPECT_NEAR(tallDiv.x * scale, scroll.x, 20);
+ EXPECT_NEAR(tallDiv.y * scale, scroll.y, 20);
+ EXPECT_FALSE(isAnchor);
+
+ // Test for Non-doubletap scaling
+ // Test zooming into div.
+ webViewImpl->computeScaleAndScrollForHitRect(WebRect(250, 250, 10, 10), WebViewImpl::FindInPage, scale, scroll, isAnchor);
+ EXPECT_NEAR(viewportWidth / (float) wideDiv.width, scale, 0.1);
+}
- // Test for Doubletap scaling
+void simulateDoubleTap(WebViewImpl* webViewImpl, WebPoint& point, float& scale)
+{
+ WebPoint scaledPoint(static_cast<int>(point.x * webViewImpl->pageScaleFactor()),
+ static_cast<int>(point.y * webViewImpl->pageScaleFactor()));
+ webViewImpl->animateZoomAroundPoint(scaledPoint, WebViewImpl::DoubleTap);
+ webViewImpl->mainFrameImpl()->frameView()->layout();
+ scale = webViewImpl->pageScaleFactor();
+}
- // Tests for zooming in and out without clamping.
- // Set device scale and scale limits so we dont get clamped.
- webViewImpl->setDeviceScaleFactor(4);
- webViewImpl->setPageScaleFactorLimits(0, 4 / webViewImpl->deviceScaleFactor());
+TEST_F(WebFrameTest, DivAutoZoomMultipleDivsTest)
+{
+ registerMockedHttpURLLoad("get_multiple_divs_for_auto_zoom_test.html");
- // Test zooming into div.
- webViewImpl->computeScaleAndScrollForHitRect(doubleTapPoint, WebViewImpl::DoubleTap, scale, scroll);
- float scaledDivWidth = divWidth * scale;
- float scaledDivHeight = divHeight * scale;
- int hScroll = ((divPosX * scale) - ((pageWidth - scaledDivWidth) / 2)) / scale;
- int vScroll = ((divPosY * scale) - ((pageHeight - scaledDivHeight) / 2)) / scale;
- EXPECT_NEAR(pageWidth / divWidth, scale, 0.1);
- EXPECT_EQ(hScroll, scroll.x);
- EXPECT_EQ(vScroll, scroll.y);
-
- // Test zoom out to overview scale.
- webViewImpl->applyScrollAndScale(WebSize(scroll.x, scroll.y), scale / webViewImpl->pageScaleFactor());
- webViewImpl->computeScaleAndScrollForHitRect(doubleTapPoint, WebViewImpl::DoubleTap, scale, scroll);
- EXPECT_FLOAT_EQ(1, scale);
- EXPECT_EQ(WebPoint(0, 0), scroll);
-
- // Tests for clamped scaling.
- // Test clamp to device scale:
- webViewImpl->applyScrollAndScale(WebSize(scroll.x, scroll.y), scale / webViewImpl->pageScaleFactor());
- webViewImpl->setDeviceScaleFactor(2.5);
- webViewImpl->computeScaleAndScrollForHitRect(doubleTapPoint, WebViewImpl::DoubleTap, scale, scroll);
- EXPECT_FLOAT_EQ(2.5, scale);
-
- // Test clamp to minimum scale:
- webViewImpl->applyScrollAndScale(WebSize(scroll.x, scroll.y), scale / webViewImpl->pageScaleFactor());
- webViewImpl->setPageScaleFactorLimits(1.5 / webViewImpl->deviceScaleFactor(), 4 / webViewImpl->deviceScaleFactor());
- webViewImpl->computeScaleAndScrollForHitRect(doubleTapPoint, WebViewImpl::DoubleTap, scale, scroll);
- EXPECT_FLOAT_EQ(1.5, scale);
- EXPECT_EQ(WebPoint(0, 0), scroll);
-
- // Test clamp to maximum scale:
- webViewImpl->applyScrollAndScale(WebSize(scroll.x, scroll.y), scale / webViewImpl->pageScaleFactor());
- webViewImpl->setDeviceScaleFactor(4);
- webViewImpl->setPageScaleFactorLimits(0, 3 / webViewImpl->deviceScaleFactor());
- webViewImpl->computeScaleAndScrollForHitRect(doubleTapPoint, WebViewImpl::DoubleTap, scale, scroll);
- EXPECT_FLOAT_EQ(3, scale);
+ DivAutoZoomTestWebViewClient client;
+ int viewportWidth = 640;
+ int viewportHeight = 480;
+ float doubleTapZoomAlreadyLegibleRatio = 1.2f;
+ client.m_windowRect = WebRect(0, 0, viewportWidth, viewportHeight);
+ WebKit::WebView* webView = FrameTestHelpers::createWebViewAndLoad(m_baseURL + "get_multiple_divs_for_auto_zoom_test.html", true, 0, &client);
+ webView->enableFixedLayoutMode(true);
+ webView->resize(WebSize(viewportWidth, viewportHeight));
+ webView->setPageScaleFactorLimits(1, 4);
+ webView->layout();
+ webView->setDeviceScaleFactor(1.5f);
- // Test for Non-doubletap scaling
- webViewImpl->setPageScaleFactor(1, WebPoint(0, 0));
- webViewImpl->setDeviceScaleFactor(4);
- webViewImpl->setPageScaleFactorLimits(0, 4 / webViewImpl->deviceScaleFactor());
- // Test zooming into div.
- webViewImpl->computeScaleAndScrollForHitRect(WebRect(250, 250, 10, 10), WebViewImpl::FindInPage, scale, scroll);
- EXPECT_NEAR(pageWidth / divWidth, scale, 0.1);
+ WebViewImpl* webViewImpl = static_cast<WebViewImpl*>(webView);
+ webViewImpl->shouldUseAnimateDoubleTapTimeZeroForTesting(true);
- // Drop any pending fake mouse events from zooming before leaving the test.
- webViewImpl->page()->mainFrame()->eventHandler()->clear();
+ WebRect topDiv(200, 100, 200, 150);
+ WebRect bottomDiv(200, 300, 200, 150);
+ WebPoint topPoint(topDiv.x + 50, topDiv.y + 50);
+ WebPoint bottomPoint(bottomDiv.x + 50, bottomDiv.y + 50);
+ float scale;
+ setScaleAndScrollAndLayout(webViewImpl, WebPoint(0, 0), (webViewImpl->minimumPageScaleFactor()) * (1 + doubleTapZoomAlreadyLegibleRatio) / 2);
+
+ // Test double tap on two different divs
+ // After first zoom, we should go back to minimum page scale with a second double tap.
+ simulateDoubleTap(webViewImpl, topPoint, scale);
+ EXPECT_FLOAT_EQ(webViewImpl->deviceScaleFactor(), scale);
+ simulateDoubleTap(webViewImpl, bottomPoint, scale);
+ EXPECT_FLOAT_EQ(webViewImpl->minimumPageScaleFactor(), scale);
+
+ // If the user pinch zooms after double tap, a second double tap should zoom back to the div.
+ simulateDoubleTap(webViewImpl, topPoint, scale);
+ EXPECT_FLOAT_EQ(webViewImpl->deviceScaleFactor(), scale);
+ webViewImpl->applyScrollAndScale(WebSize(), 0.6f);
+ simulateDoubleTap(webViewImpl, bottomPoint, scale);
+ EXPECT_FLOAT_EQ(webViewImpl->deviceScaleFactor(), scale);
+}
+
+TEST_F(WebFrameTest, DivAutoZoomScaleBoundsTest)
+{
+ registerMockedHttpURLLoad("get_scale_bounds_check_for_auto_zoom_test.html");
+
+ DivAutoZoomTestWebViewClient client;
+ int viewportWidth = 640;
+ int viewportHeight = 480;
+ float doubleTapZoomAlreadyLegibleRatio = 1.2f;
+ client.m_windowRect = WebRect(0, 0, viewportWidth, viewportHeight);
+ WebKit::WebView* webView = FrameTestHelpers::createWebViewAndLoad(m_baseURL + "get_scale_bounds_check_for_auto_zoom_test.html", true, 0, &client);
+ webView->enableFixedLayoutMode(true);
+ webView->resize(WebSize(viewportWidth, viewportHeight));
+ webView->setPageScaleFactorLimits(1, 4);
+ webView->layout();
+ webView->setDeviceScaleFactor(1.5f);
+
+ WebViewImpl* webViewImpl = static_cast<WebViewImpl*>(webView);
+ webViewImpl->shouldUseAnimateDoubleTapTimeZeroForTesting(true);
+ float doubleTapZoomAlreadyLegibleScale = webViewImpl->minimumPageScaleFactor() * doubleTapZoomAlreadyLegibleRatio;
+
+ WebRect div(200, 100, 200, 150);
+ WebPoint doubleTapPoint(div.x + 50, div.y + 50);
+ float scale;
+
+ // Test double tap scale bounds.
+ // minimumPageScale < doubleTapZoomAlreadyLegibleScale < deviceDpiScale
+ setScaleAndScrollAndLayout(webViewImpl, WebPoint(0, 0), (webViewImpl->minimumPageScaleFactor()) * (1 + doubleTapZoomAlreadyLegibleRatio) / 2);
+ simulateDoubleTap(webViewImpl, doubleTapPoint, scale);
+ EXPECT_FLOAT_EQ(webViewImpl->deviceScaleFactor(), scale);
+ simulateDoubleTap(webViewImpl, doubleTapPoint, scale);
+ EXPECT_FLOAT_EQ(webViewImpl->minimumPageScaleFactor(), scale);
+ simulateDoubleTap(webViewImpl, doubleTapPoint, scale);
+ EXPECT_FLOAT_EQ(webViewImpl->deviceScaleFactor(), scale);
+
+ // Zoom in to reset double_tap_zoom_in_effect flag.
+ webViewImpl->applyScrollAndScale(WebSize(), 1.1f);
+ // deviceDpiScale < minimumPageScale < doubleTapZoomAlreadyLegibleScale
+ webViewImpl->setDeviceScaleFactor(0.5f);
+ setScaleAndScrollAndLayout(webViewImpl, WebPoint(0, 0), (webViewImpl->minimumPageScaleFactor()) * (1 + doubleTapZoomAlreadyLegibleRatio) / 2);
+ simulateDoubleTap(webViewImpl, doubleTapPoint, scale);
+ EXPECT_FLOAT_EQ(webViewImpl->minimumPageScaleFactor(), scale);
+ simulateDoubleTap(webViewImpl, doubleTapPoint, scale);
+ EXPECT_FLOAT_EQ(doubleTapZoomAlreadyLegibleScale, scale);
+ simulateDoubleTap(webViewImpl, doubleTapPoint, scale);
+ EXPECT_FLOAT_EQ(webViewImpl->minimumPageScaleFactor(), scale);
+
+ // Zoom in to reset double_tap_zoom_in_effect flag.
+ webViewImpl->applyScrollAndScale(WebSize(), 1.1f);
+ // minimumPageScale < doubleTapZoomAlreadyLegibleScale < deviceDpiScale
+ webViewImpl->setDeviceScaleFactor(1.1f);
+ setScaleAndScrollAndLayout(webViewImpl, WebPoint(0, 0), (webViewImpl->minimumPageScaleFactor()) * (1 + doubleTapZoomAlreadyLegibleRatio) / 2);
+ simulateDoubleTap(webViewImpl, doubleTapPoint, scale);
+ EXPECT_FLOAT_EQ(webViewImpl->minimumPageScaleFactor(), scale);
+ simulateDoubleTap(webViewImpl, doubleTapPoint, scale);
+ EXPECT_FLOAT_EQ(doubleTapZoomAlreadyLegibleScale, scale);
+ simulateDoubleTap(webViewImpl, doubleTapPoint, scale);
+ EXPECT_FLOAT_EQ(webViewImpl->minimumPageScaleFactor(), scale);
+}
+
+// This test depends on code that is compiled conditionally. We likely need to
+// add the proper ifdef when re-enabling it. See
+// https://bugs.webkit.org/show_bug.cgi?id=98558
+TEST_F(WebFrameTest, DISABLED_DivScrollIntoEditableTest)
+{
+ registerMockedHttpURLLoad("get_scale_for_zoom_into_editable_test.html");
+
+ DivAutoZoomTestWebViewClient client;
+ int viewportWidth = 640;
+ int viewportHeight = 480;
+ float leftBoxRatio = 0.3f;
+ int caretPadding = 10;
+ int minReadableCaretHeight = 18;
+ client.m_windowRect = WebRect(0, 0, viewportWidth, viewportHeight);
+ WebKit::WebView* webView = FrameTestHelpers::createWebViewAndLoad(m_baseURL + "get_scale_for_zoom_into_editable_test.html", true, 0, &client);
+ webView->enableFixedLayoutMode(true);
+ webView->resize(WebSize(viewportWidth, viewportHeight));
+ webView->setPageScaleFactorLimits(1, 10);
+ webView->layout();
+ webView->setDeviceScaleFactor(1.5f);
+ webView->settings()->setAutoZoomFocusedNodeToLegibleScale(true);
+
+ WebViewImpl* webViewImpl = static_cast<WebViewImpl*>(webView);
+ webViewImpl->shouldUseAnimateDoubleTapTimeZeroForTesting(true);
+
+ WebRect editBoxWithText(200, 200, 250, 20);
+ WebRect editBoxWithNoText(200, 250, 250, 20);
+
+ // Test scrolling the focused node
+ // The edit box is shorter and narrower than the viewport when legible.
+ setScaleAndScrollAndLayout(webView, WebPoint(0, 0), 1);
+ WebRect rect, caret;
+ webViewImpl->selectionBounds(caret, rect);
+ webView->scrollFocusedNodeIntoRect(rect);
+ // The edit box should be left aligned with a margin for possible label.
+ int hScroll = editBoxWithText.x * webView->pageScaleFactor() - leftBoxRatio * viewportWidth;
+ EXPECT_EQ(hScroll, webView->mainFrame()->scrollOffset().width);
+ int vScroll = editBoxWithText.y * webView->pageScaleFactor() - (viewportHeight - editBoxWithText.height * webView->pageScaleFactor()) / 2;
+ EXPECT_EQ(vScroll, webView->mainFrame()->scrollOffset().height);
+ EXPECT_FLOAT_EQ(webView->deviceScaleFactor() * minReadableCaretHeight / caret.height, webView->pageScaleFactor());
+
+ // The edit box is wider than the viewport when legible.
+ webView->setDeviceScaleFactor(4);
+ setScaleAndScrollAndLayout(webView, WebPoint(0, 0), 1);
+ webViewImpl->selectionBounds(caret, rect);
+ webView->scrollFocusedNodeIntoRect(rect);
+ // The caret should be right aligned since the caret would be offscreen when the edit box is left aligned.
+ hScroll = (caret.x + caret.width) * webView->pageScaleFactor() + caretPadding - viewportWidth;
+ EXPECT_EQ(hScroll, webView->mainFrame()->scrollOffset().width);
+ EXPECT_FLOAT_EQ(webView->deviceScaleFactor() * minReadableCaretHeight / caret.height, webView->pageScaleFactor());
+
+ setScaleAndScrollAndLayout(webView, WebPoint(0, 0), 1);
+ // Move focus to edit box with text.
+ webView->advanceFocus(false);
+ webViewImpl->selectionBounds(caret, rect);
+ webView->scrollFocusedNodeIntoRect(rect);
+ // The edit box should be left aligned.
+ hScroll = editBoxWithNoText.x * webView->pageScaleFactor();
+ EXPECT_EQ(hScroll, webView->mainFrame()->scrollOffset().width);
+ vScroll = editBoxWithNoText.y * webView->pageScaleFactor() - (viewportHeight - editBoxWithNoText.height * webView->pageScaleFactor()) / 2;
+ EXPECT_EQ(vScroll, webView->mainFrame()->scrollOffset().height);
+ EXPECT_FLOAT_EQ(webView->deviceScaleFactor() * minReadableCaretHeight / caret.height, webView->pageScaleFactor());
+
+ // Move focus back to the first edit box.
+ webView->advanceFocus(true);
+ webViewImpl->selectionBounds(caret, rect);
+ // The position should have stayed the same since this box was already on screen with the right scale.
+ EXPECT_EQ(vScroll, webView->mainFrame()->scrollOffset().height);
+ EXPECT_EQ(hScroll, webView->mainFrame()->scrollOffset().width);
}
#endif
@@ -900,6 +1080,8 @@ TEST_F(WebFrameTest, FindInPageMatchRects)
WebFrameImpl* mainFrame = static_cast<WebFrameImpl*>(webView->mainFrame());
EXPECT_TRUE(mainFrame->find(kFindIdentifier, searchText, options, false, 0));
+ mainFrame->resetMatchCount();
+
for (WebFrame* frame = mainFrame; frame; frame = frame->traverseNext(false))
frame->scopeStringMatches(kFindIdentifier, searchText, options, true);
@@ -990,6 +1172,129 @@ TEST_F(WebFrameTest, FindInPageMatchRects)
webView->close();
}
+TEST_F(WebFrameTest, FindOnDetachedFrame)
+{
+ registerMockedHttpURLLoad("find_in_page.html");
+ registerMockedHttpURLLoad("find_in_page_frame.html");
+
+ FindUpdateWebFrameClient client;
+ WebView* webView = FrameTestHelpers::createWebViewAndLoad(m_baseURL + "find_in_page.html", true, &client);
+ webView->resize(WebSize(640, 480));
+ webView->layout();
+ webkit_support::RunAllPendingMessages();
+
+ static const char* kFindString = "result";
+ static const int kFindIdentifier = 12345;
+
+ WebFindOptions options;
+ WebString searchText = WebString::fromUTF8(kFindString);
+ WebFrameImpl* mainFrame = static_cast<WebFrameImpl*>(webView->mainFrame());
+ WebFrameImpl* secondFrame = static_cast<WebFrameImpl*>(mainFrame->traverseNext(false));
+ RefPtr<WebCore::Frame> holdSecondFrame = secondFrame->frame();
+
+ // Detach the frame before finding.
+ EXPECT_TRUE(mainFrame->document().getElementById("frame").remove());
+
+ EXPECT_TRUE(mainFrame->find(kFindIdentifier, searchText, options, false, 0));
+ EXPECT_FALSE(secondFrame->find(kFindIdentifier, searchText, options, false, 0));
+
+ webkit_support::RunAllPendingMessages();
+ EXPECT_FALSE(client.findResultsAreReady());
+
+ mainFrame->resetMatchCount();
+
+ for (WebFrame* frame = mainFrame; frame; frame = frame->traverseNext(false))
+ frame->scopeStringMatches(kFindIdentifier, searchText, options, true);
+
+ webkit_support::RunAllPendingMessages();
+ EXPECT_TRUE(client.findResultsAreReady());
+
+ holdSecondFrame.release();
+ webView->close();
+}
+
+TEST_F(WebFrameTest, FindDetachFrameBeforeScopeStrings)
+{
+ registerMockedHttpURLLoad("find_in_page.html");
+ registerMockedHttpURLLoad("find_in_page_frame.html");
+
+ FindUpdateWebFrameClient client;
+ WebView* webView = FrameTestHelpers::createWebViewAndLoad(m_baseURL + "find_in_page.html", true, &client);
+ webView->resize(WebSize(640, 480));
+ webView->layout();
+ webkit_support::RunAllPendingMessages();
+
+ static const char* kFindString = "result";
+ static const int kFindIdentifier = 12345;
+
+ WebFindOptions options;
+ WebString searchText = WebString::fromUTF8(kFindString);
+ WebFrameImpl* mainFrame = static_cast<WebFrameImpl*>(webView->mainFrame());
+ WebFrameImpl* secondFrame = static_cast<WebFrameImpl*>(mainFrame->traverseNext(false));
+ RefPtr<WebCore::Frame> holdSecondFrame = secondFrame->frame();
+
+ for (WebFrame* frame = mainFrame; frame; frame = frame->traverseNext(false))
+ EXPECT_TRUE(frame->find(kFindIdentifier, searchText, options, false, 0));
+
+ webkit_support::RunAllPendingMessages();
+ EXPECT_FALSE(client.findResultsAreReady());
+
+ // Detach the frame between finding and scoping.
+ EXPECT_TRUE(mainFrame->document().getElementById("frame").remove());
+
+ mainFrame->resetMatchCount();
+
+ for (WebFrame* frame = mainFrame; frame; frame = frame->traverseNext(false))
+ frame->scopeStringMatches(kFindIdentifier, searchText, options, true);
+
+ webkit_support::RunAllPendingMessages();
+ EXPECT_TRUE(client.findResultsAreReady());
+
+ holdSecondFrame.release();
+ webView->close();
+}
+
+TEST_F(WebFrameTest, FindDetachFrameWhileScopingStrings)
+{
+ registerMockedHttpURLLoad("find_in_page.html");
+ registerMockedHttpURLLoad("find_in_page_frame.html");
+
+ FindUpdateWebFrameClient client;
+ WebView* webView = FrameTestHelpers::createWebViewAndLoad(m_baseURL + "find_in_page.html", true, &client);
+ webView->resize(WebSize(640, 480));
+ webView->layout();
+ webkit_support::RunAllPendingMessages();
+
+ static const char* kFindString = "result";
+ static const int kFindIdentifier = 12345;
+
+ WebFindOptions options;
+ WebString searchText = WebString::fromUTF8(kFindString);
+ WebFrameImpl* mainFrame = static_cast<WebFrameImpl*>(webView->mainFrame());
+ WebFrameImpl* secondFrame = static_cast<WebFrameImpl*>(mainFrame->traverseNext(false));
+ RefPtr<WebCore::Frame> holdSecondFrame = secondFrame->frame();
+
+ for (WebFrame* frame = mainFrame; frame; frame = frame->traverseNext(false))
+ EXPECT_TRUE(frame->find(kFindIdentifier, searchText, options, false, 0));
+
+ webkit_support::RunAllPendingMessages();
+ EXPECT_FALSE(client.findResultsAreReady());
+
+ mainFrame->resetMatchCount();
+
+ for (WebFrame* frame = mainFrame; frame; frame = frame->traverseNext(false))
+ frame->scopeStringMatches(kFindIdentifier, searchText, options, true);
+
+ // The first scopeStringMatches will have reset the state. Detach before it actually scopes.
+ EXPECT_TRUE(mainFrame->document().getElementById("frame").remove());
+
+ webkit_support::RunAllPendingMessages();
+ EXPECT_TRUE(client.findResultsAreReady());
+
+ holdSecondFrame.release();
+ webView->close();
+}
+
static WebView* createWebViewForTextSelection(const std::string& url)
{
WebView* webView = FrameTestHelpers::createWebViewAndLoad(url, true);
diff --git a/Source/WebKit/chromium/tests/WebImageTest.cpp b/Source/WebKit/chromium/tests/WebImageTest.cpp
index f968176cf..2f44e34b3 100644
--- a/Source/WebKit/chromium/tests/WebImageTest.cpp
+++ b/Source/WebKit/chromium/tests/WebImageTest.cpp
@@ -88,6 +88,15 @@ TEST(WebImageTest, ICOImage)
EXPECT_EQ(SkColorSetARGB(255, 0, 0, 0), images[1].getSkBitmap().getColor(0, 0));
}
+TEST(WebImageTest, ICOValidHeaderMissingBitmap)
+{
+ RefPtr<SharedBuffer> data = readFile("valid_header_missing_bitmap.ico");
+ ASSERT_TRUE(data.get());
+
+ WebVector<WebImage> images = WebImage::framesFromData(WebData(data));
+ ASSERT_TRUE(images.isEmpty());
+}
+
TEST(WebImageTest, BadImage)
{
const char badImage[] = "hello world";
diff --git a/Source/WebKit/chromium/tests/WebInputEventFactoryTestMac.mm b/Source/WebKit/chromium/tests/WebInputEventFactoryTestMac.mm
new file mode 100644
index 000000000..73a29bcd1
--- /dev/null
+++ b/Source/WebKit/chromium/tests/WebInputEventFactoryTestMac.mm
@@ -0,0 +1,84 @@
+/*
+ * 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:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * 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.
+ * * Neither the name of Google Inc. 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 THE COPYRIGHT HOLDERS AND 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 THE COPYRIGHT
+ * OWNER 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"
+
+#import <Cocoa/Cocoa.h>
+#include <gtest/gtest.h>
+
+#include "KeyboardEvent.h"
+#include "WebInputEvent.h"
+#include "WebInputEventFactory.h"
+
+using WebKit::WebInputEventFactory;
+using WebKit::WebKeyboardEvent;
+
+namespace {
+
+NSEvent* BuildFakeKeyEvent(NSUInteger keyCode, unichar character, NSUInteger modifierFlags)
+{
+ NSString* string = [NSString stringWithCharacters:&character length:1];
+ return [NSEvent keyEventWithType:NSKeyDown
+ location:NSZeroPoint
+ modifierFlags:modifierFlags
+ timestamp:0.0
+ windowNumber:0
+ context:nil
+ characters:string
+ charactersIgnoringModifiers:string
+ isARepeat:NO
+ keyCode:keyCode];
+}
+
+} // namespace
+
+// Test that arrow keys don't have numpad modifier set.
+TEST(WebInputEventFactoryTestMac, ArrowKeyNumPad)
+{
+ // Left
+ NSEvent* macEvent = BuildFakeKeyEvent(0x7B, NSLeftArrowFunctionKey, NSNumericPadKeyMask);
+ WebKeyboardEvent webEvent = WebInputEventFactory::keyboardEvent(macEvent);
+ EXPECT_EQ(0, webEvent.modifiers);
+
+ // Right
+ macEvent = BuildFakeKeyEvent(0x7C, NSRightArrowFunctionKey, NSNumericPadKeyMask);
+ webEvent = WebInputEventFactory::keyboardEvent(macEvent);
+ EXPECT_EQ(0, webEvent.modifiers);
+
+ // Down
+ macEvent = BuildFakeKeyEvent(0x7D, NSDownArrowFunctionKey, NSNumericPadKeyMask);
+ webEvent = WebInputEventFactory::keyboardEvent(macEvent);
+ EXPECT_EQ(0, webEvent.modifiers);
+
+ // Up
+ macEvent = BuildFakeKeyEvent(0x7E, NSUpArrowFunctionKey, NSNumericPadKeyMask);
+ webEvent = WebInputEventFactory::keyboardEvent(macEvent);
+ EXPECT_EQ(0, webEvent.modifiers);
+}
diff --git a/Source/WebKit/chromium/tests/WebPageNewSerializerTest.cpp b/Source/WebKit/chromium/tests/WebPageNewSerializerTest.cpp
index 3ea4fcf9e..9d4b60acd 100644
--- a/Source/WebKit/chromium/tests/WebPageNewSerializerTest.cpp
+++ b/Source/WebKit/chromium/tests/WebPageNewSerializerTest.cpp
@@ -88,6 +88,7 @@ public:
, m_xhtmlMimeType(WebString::fromUTF8("application/xhtml+xml"))
, m_cssMimeType(WebString::fromUTF8("text/css"))
, m_pngMimeType(WebString::fromUTF8("image/png"))
+ , m_svgMimeType(WebString::fromUTF8("image/svg+xml"))
{
}
@@ -148,6 +149,7 @@ protected:
const WebString& xhtmlMimeType() const { return m_xhtmlMimeType; }
const WebString& cssMimeType() const { return m_cssMimeType; }
const WebString& pngMimeType() const { return m_pngMimeType; }
+ const WebString& svgMimeType() const { return m_svgMimeType; }
static bool resourceVectorContains(const WebVector<WebPageSerializer::Resource>& resources, const char* url, const char* mimeType)
{
@@ -167,6 +169,7 @@ private:
WebString m_xhtmlMimeType;
WebString m_cssMimeType;
WebString m_pngMimeType;
+ WebString m_svgMimeType;
TestWebFrameClient m_webFrameClient;
};
@@ -329,4 +332,20 @@ TEST_F(WebPageNewSerializeTest, FAILS_TestMHTMLEncoding)
EXPECT_EQ(12, sectionCheckedCount);
}
+// Test that we don't regress https://bugs.webkit.org/show_bug.cgi?id=99105
+TEST_F(WebPageNewSerializeTest, SVGImageDontCrash)
+{
+ WebURL pageUrl = toKURL("http://www.test.com");
+ WebURL imageUrl = toKURL("http://www.test.com/green_rectangle.svg");
+
+ registerMockedURLLoad(pageUrl, WebString::fromUTF8("page_with_svg_image.html"), WebString::fromUTF8("pageserializer/"), htmlMimeType());
+ registerMockedURLLoad(imageUrl, WebString::fromUTF8("green_rectangle.svg"), WebString::fromUTF8("pageserializer/"), svgMimeType());
+
+ loadURLInTopFrame(pageUrl);
+
+ WebCString mhtml = WebPageSerializer::serializeToMHTML(m_webView);
+ // We expect some data to be generated.
+ EXPECT_GT(mhtml.length(), 50U);
+}
+
}
diff --git a/Source/WebKit/chromium/tests/WebSocketExtensionDispatcherTest.cpp b/Source/WebKit/chromium/tests/WebSocketExtensionDispatcherTest.cpp
index 358983b83..52905bab1 100644
--- a/Source/WebKit/chromium/tests/WebSocketExtensionDispatcherTest.cpp
+++ b/Source/WebKit/chromium/tests/WebSocketExtensionDispatcherTest.cpp
@@ -27,9 +27,11 @@
#include "WebSocketExtensionDispatcher.h"
+#include "WebSocketExtensionParser.h"
#include "WebSocketExtensionProcessor.h"
#include <gtest/gtest.h>
+#include <wtf/text/CString.h>
#include <wtf/text/StringHash.h>
using namespace WebCore;
@@ -103,10 +105,10 @@ TEST_F(WebSocketExtensionDispatcherTest, TestParameters)
EXPECT_EQ(2, m_parsedParameters[0].size());
HashMap<String, String>::iterator parameter = m_parsedParameters[0].find("max-channels");
EXPECT_TRUE(parameter != m_parsedParameters[0].end());
- EXPECT_EQ("4", parameter->second);
+ EXPECT_EQ("4", parameter->value);
parameter = m_parsedParameters[0].find("flow-control");
EXPECT_TRUE(parameter != m_parsedParameters[0].end());
- EXPECT_TRUE(parameter->second.isNull());
+ EXPECT_TRUE(parameter->value.isNull());
}
TEST_F(WebSocketExtensionDispatcherTest, TestMultiple)
@@ -131,12 +133,12 @@ TEST_F(WebSocketExtensionDispatcherTest, TestMultiple)
const HashMap<String, String>& parsedParameters = m_parsedParameters[i];
EXPECT_EQ(expected[i].parameters.size(), m_parsedParameters[i].size());
for (HashMap<String, String>::const_iterator iterator = expectedParameters.begin(); iterator != expectedParameters.end(); ++iterator) {
- HashMap<String, String>::const_iterator parsed = parsedParameters.find(iterator->first);
+ HashMap<String, String>::const_iterator parsed = parsedParameters.find(iterator->key);
EXPECT_TRUE(parsed != parsedParameters.end());
- if (iterator->second.isNull())
- EXPECT_TRUE(parsed->second.isNull());
+ if (iterator->value.isNull())
+ EXPECT_TRUE(parsed->value.isNull());
else
- EXPECT_EQ(iterator->second, parsed->second);
+ EXPECT_EQ(iterator->value, parsed->value);
}
}
}
@@ -176,4 +178,34 @@ TEST_F(WebSocketExtensionDispatcherTest, TestInvalid)
}
}
+// Tests for the most complex example at http://tools.ietf.org/html/draft-ietf-hybi-permessage-compression-01#section-3.1
+TEST_F(WebSocketExtensionDispatcherTest, TestPerMessageCompressExample)
+{
+ addMockProcessor("permessage-compress");
+ addMockProcessor("bar");
+ EXPECT_TRUE(m_extensions.processHeaderValue("permessage-compress; method=\"foo; x=\\\"Hello World\\\", bar\""));
+ EXPECT_EQ(1U, m_parsedExtensionTokens.size());
+ EXPECT_EQ("permessage-compress", m_parsedExtensionTokens[0]);
+ String methodParameter = m_parsedParameters[0].find("method")->value;
+ EXPECT_EQ("foo; x=\"Hello World\", bar", methodParameter);
+
+ CString methodValue = methodParameter.ascii();
+ WebSocketExtensionParser parser(methodValue.data(), methodValue.data() + methodValue.length());
+
+ String token1;
+ HashMap<String, String> parameters1;
+ EXPECT_TRUE(parser.parseExtension(token1, parameters1));
+ EXPECT_EQ("foo", token1);
+ EXPECT_EQ(1, parameters1.size());
+ HashMap<String, String>::iterator xparameter = parameters1.find("x");
+ EXPECT_EQ("x", xparameter->key);
+ EXPECT_EQ("Hello World", xparameter->value);
+
+ String token2;
+ HashMap<String, String> parameters2;
+ EXPECT_TRUE(parser.parseExtension(token2, parameters2));
+ EXPECT_EQ("bar", token2);
+ EXPECT_EQ(0, parameters2.size());
+}
+
}
diff --git a/Source/WebKit/chromium/tests/WebViewTest.cpp b/Source/WebKit/chromium/tests/WebViewTest.cpp
index d478aad92..1929c1ba6 100644
--- a/Source/WebKit/chromium/tests/WebViewTest.cpp
+++ b/Source/WebKit/chromium/tests/WebViewTest.cpp
@@ -585,24 +585,6 @@ TEST_F(WebViewTest, DetectContentAroundPosition)
EXPECT_FALSE(client.contentDetectionRequested());
client.reset();
- // Content detection should still work on click, mouse and touch event listeners for long taps
- // as long as we're not tapping on links.
- EXPECT_TRUE(tapElementById(webView, WebInputEvent::GestureLongPress, clickListener));
- EXPECT_TRUE(client.contentDetectionRequested());
- client.reset();
-
- EXPECT_TRUE(tapElementById(webView, WebInputEvent::GestureLongPress, touchstartListener));
- EXPECT_TRUE(client.contentDetectionRequested());
- client.reset();
-
- EXPECT_TRUE(tapElementById(webView, WebInputEvent::GestureLongPress, mousedownListener));
- EXPECT_TRUE(client.contentDetectionRequested());
- client.reset();
-
- EXPECT_TRUE(tapElementById(webView, WebInputEvent::GestureLongPress, link));
- EXPECT_FALSE(client.contentDetectionRequested());
- client.reset();
-
// Content detection should work normally without these event listeners.
// The click listener in the body should be ignored as a special case.
EXPECT_TRUE(tapElementById(webView, WebInputEvent::GestureTap, noListener));
@@ -647,4 +629,26 @@ TEST_F(WebViewTest, ClientTapHandling)
webView->close();
}
+#if OS(ANDROID)
+TEST_F(WebViewTest, LongPressSelection)
+{
+ URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(m_baseURL.c_str()), WebString::fromUTF8("longpress_selection.html"));
+
+ WebView* webView = FrameTestHelpers::createWebViewAndLoad(m_baseURL + "longpress_selection.html", true);
+ webView->resize(WebSize(500, 300));
+ webView->layout();
+ webkit_support::RunAllPendingMessages();
+
+ WebString target = WebString::fromUTF8("target");
+ WebString onselectstartfalse = WebString::fromUTF8("onselectstartfalse");
+ WebFrameImpl* frame = static_cast<WebFrameImpl*>(webView->mainFrame());
+
+ EXPECT_TRUE(tapElementById(webView, WebInputEvent::GestureLongPress, onselectstartfalse));
+ EXPECT_EQ("", std::string(frame->selectionAsText().utf8().data()));
+ EXPECT_TRUE(tapElementById(webView, WebInputEvent::GestureLongPress, target));
+ EXPECT_EQ("testword", std::string(frame->selectionAsText().utf8().data()));
+ webView->close();
+}
+#endif
+
}
diff --git a/Source/WebKit/chromium/tests/data/clipped-body.html b/Source/WebKit/chromium/tests/data/clipped-body.html
new file mode 100644
index 000000000..4ebf169ad
--- /dev/null
+++ b/Source/WebKit/chromium/tests/data/clipped-body.html
@@ -0,0 +1,21 @@
+<!DOCTYPE html>
+<html>
+
+<head>
+ <style>
+ html, body {
+ overflow-x: hidden;
+ }
+ #content {
+ background: silver;
+ width: 1000px;
+ height: 1000px;
+ }
+ </style>
+<head>
+
+<body>
+ <div id="content"></div>
+</body>
+
+</html>
diff --git a/Source/WebKit/chromium/tests/data/find_in_page.html b/Source/WebKit/chromium/tests/data/find_in_page.html
index 643073a16..f5d28a644 100644
--- a/Source/WebKit/chromium/tests/data/find_in_page.html
+++ b/Source/WebKit/chromium/tests/data/find_in_page.html
@@ -6,7 +6,7 @@
<body>
This a find-in-page match rect test.</br>
result 00</br>
-<iframe src="find_in_page_frame.html" height="300" scrolling="yes"></iframe>
+<iframe src="find_in_page_frame.html" id="frame" height="300" scrolling="yes"></iframe>
</br>
result 01
</body>
diff --git a/Source/WebKit/chromium/tests/data/get_multiple_divs_for_auto_zoom_test.html b/Source/WebKit/chromium/tests/data/get_multiple_divs_for_auto_zoom_test.html
new file mode 100644
index 000000000..5f2e6442f
--- /dev/null
+++ b/Source/WebKit/chromium/tests/data/get_multiple_divs_for_auto_zoom_test.html
@@ -0,0 +1,10 @@
+<html>
+ <body>
+ <div style="background-color: green; position: absolute; left: 200px; top: 100px; width: 200px; height: 150px">
+ <p id="Div">Top Div</p>
+ </div>
+ <div style="background-color: green; position: absolute; left: 200px; top: 300px; width: 200px; height: 150px">
+ <p id="Div">Bottom Div</p>
+ </div>
+ </body>
+</html>
diff --git a/Source/WebKit/chromium/tests/data/get_scale_bounds_check_for_auto_zoom_test.html b/Source/WebKit/chromium/tests/data/get_scale_bounds_check_for_auto_zoom_test.html
new file mode 100644
index 000000000..9cc8e9c16
--- /dev/null
+++ b/Source/WebKit/chromium/tests/data/get_scale_bounds_check_for_auto_zoom_test.html
@@ -0,0 +1,7 @@
+<html>
+ <body>
+ <div style="background-color: green; position: absolute; left: 200px; top: 100px; width: 200px; height: 400px">
+ <p id="Div">Div</p>
+ </div>
+ </body>
+</html>
diff --git a/Source/WebKit/chromium/tests/data/get_scale_for_auto_zoom_into_div_test.html b/Source/WebKit/chromium/tests/data/get_scale_for_auto_zoom_into_div_test.html
index 1817dc47d..95e7b3787 100644
--- a/Source/WebKit/chromium/tests/data/get_scale_for_auto_zoom_into_div_test.html
+++ b/Source/WebKit/chromium/tests/data/get_scale_for_auto_zoom_into_div_test.html
@@ -1,13 +1,10 @@
<html>
<body>
- <div style="background-color: green; position: absolute; left: 0px; top: 0px; width: 640px; height: 480px">
- <p>Top Div</p>
- <div style="background-color: white; position: absolute; left: 200px; top: 200px; width: 200px; height: 150px">
- <p id="innerDiv">Div to zoom to</p>
- <div style="background-color: red; position: fixed; left: 220px; top: 350px; width: 160px; height: 40px">
- <p id="innerInnerDiv">Div NOT to zoom to</p>
- </div>
- </div>
+ <div style="background-color: green; position: absolute; left: 200px; top: 100px; width: 400px; height: 150px">
+ <p id="wideDiv">Wide div</p>
+ </div>
+ <div style="background-color: green; position: absolute; left: 200px; top: 300px; width: 400px; height: 800">
+ <p id="tallDiv">Tall div</p>
</div>
</body>
</html>
diff --git a/Source/WebKit/chromium/tests/data/get_scale_for_zoom_into_editable_test.html b/Source/WebKit/chromium/tests/data/get_scale_for_zoom_into_editable_test.html
new file mode 100644
index 000000000..91c748e30
--- /dev/null
+++ b/Source/WebKit/chromium/tests/data/get_scale_for_zoom_into_editable_test.html
@@ -0,0 +1,16 @@
+<html>
+<head>
+<script>
+function getfocus()
+{
+var textfield = document.getElementById('EditBoxWithText');
+textfield.focus();
+textfield.setSelectionRange(textfield.value.length,textfield.value.length);
+}
+</script>
+</head>
+ <body onload="getfocus()">
+ <input id="EditBoxWithText" style=" position: absolute; left: 200px; top: 200px; width: 250; height:20" value = "Long text to fill the edit box" type="text">
+ <input id="EditBoxWithNoText" style=" position: absolute; left: 200px; top: 250px; width: 250; height:20" type="text">
+ </body>
+</html>
diff --git a/Source/WebKit/chromium/tests/data/longpress_selection.html b/Source/WebKit/chromium/tests/data/longpress_selection.html
new file mode 100644
index 000000000..866994f9b
--- /dev/null
+++ b/Source/WebKit/chromium/tests/data/longpress_selection.html
@@ -0,0 +1,23 @@
+<!DOCTYPE html>
+<html>
+<head>
+<style>
+span {
+ font-size: 300%;
+}
+</style>
+</head>
+<body>
+Hello this is some text for testing. Here is a
+<span id="target">
+testword
+</span>
+that we should be able to select by longpressing.
+
+To test onselectstart, here is
+<span id="onselectstartfalse" onselectstart="return false;">
+anotherbitoftext
+</span>
+that we should not be able to select.
+</body>
+</html>
diff --git a/Source/WebKit/chromium/tests/data/pageserializer/green_rectangle.svg b/Source/WebKit/chromium/tests/data/pageserializer/green_rectangle.svg
new file mode 100644
index 000000000..75307187a
--- /dev/null
+++ b/Source/WebKit/chromium/tests/data/pageserializer/green_rectangle.svg
@@ -0,0 +1,11 @@
+<?xml version="1.0"?>
+<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN"
+ "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
+
+<svg xmlns="http://www.w3.org/2000/svg" version="1.1"
+ width="120" height="120" viewBox="0 0 236 120">
+ <rect x="14" y="23" width="250" height="50" fill="green"
+ stroke="black" stroke-width="1" />
+ <rect x="14" y="23" width="250" height="50" fill="green"
+ stroke="black" stroke-width="1" />
+</svg>
diff --git a/Source/WebKit/chromium/tests/data/pageserializer/page_with_svg_image.html b/Source/WebKit/chromium/tests/data/pageserializer/page_with_svg_image.html
new file mode 100644
index 000000000..a3eb7b88d
--- /dev/null
+++ b/Source/WebKit/chromium/tests/data/pageserializer/page_with_svg_image.html
@@ -0,0 +1,6 @@
+<html>
+<body>
+SVG to the max!<br>
+<img src="green_rectangle.svg"/>
+</body>
+</html>
diff --git a/Source/WebKit/chromium/tests/data/valid_header_missing_bitmap.ico b/Source/WebKit/chromium/tests/data/valid_header_missing_bitmap.ico
new file mode 100755
index 000000000..5e4cfcec5
--- /dev/null
+++ b/Source/WebKit/chromium/tests/data/valid_header_missing_bitmap.ico
Binary files differ