OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "bindings/core/v8/ScriptValueSerializer.h" | 5 #include "bindings/core/v8/ScriptValueSerializer.h" |
6 | 6 |
7 #include "bindings/core/v8/ScriptController.h" | 7 #include "bindings/core/v8/ScriptController.h" |
8 #include "core/layout/LayoutTestHelper.h" | 8 #include "core/layout/LayoutTestHelper.h" |
9 #include "platform/testing/HistogramTester.h" | 9 #include "platform/testing/HistogramTester.h" |
| 10 #include "wtf/Alignment.h" |
10 | 11 |
11 namespace blink { | 12 namespace blink { |
12 | 13 |
13 class ScriptValueSerializerTest : public RenderingTest { | 14 class ScriptValueSerializerTest : public RenderingTest { |
14 public: | 15 public: |
15 FrameSettingOverrideFunction settingOverrider() const override | 16 FrameSettingOverrideFunction settingOverrider() const override |
16 { | 17 { |
17 return &overrideSettings; | 18 return &overrideSettings; |
18 } | 19 } |
19 | 20 |
(...skipping 16 matching lines...) Expand all Loading... |
36 | 37 |
37 // Two JS objects: the outer object and the array. | 38 // Two JS objects: the outer object and the array. |
38 histogramTester.expectUniqueSample( | 39 histogramTester.expectUniqueSample( |
39 "Blink.ScriptValueSerializer.JSObjectCount", 2, 1); | 40 "Blink.ScriptValueSerializer.JSObjectCount", 2, 1); |
40 | 41 |
41 // One DOM wrapper: the blob. | 42 // One DOM wrapper: the blob. |
42 histogramTester.expectUniqueSample( | 43 histogramTester.expectUniqueSample( |
43 "Blink.ScriptValueSerializer.DOMWrapperCount", 1, 1); | 44 "Blink.ScriptValueSerializer.DOMWrapperCount", 1, 1); |
44 } | 45 } |
45 | 46 |
| 47 TEST_F(ScriptValueSerializerTest, Uint64Decode) |
| 48 { |
| 49 // Even large 64-bit integers should decode properly. |
| 50 const uint64_t expected = 0x123456789abcdef0; |
| 51 WTF_ALIGNED(const uint8_t, buffer[], sizeof(UChar)) = { 0xf0, 0xbd, 0xf3, 0x
d5, 0x89, 0xcf, 0x95, 0x9a, 0x92, 0x00 }; |
| 52 BlobDataHandleMap blobDataHandleMap; |
| 53 SerializedScriptValueReader reader(buffer, sizeof(buffer), nullptr, blobData
HandleMap, ScriptState::forMainWorld(document().frame())); |
| 54 uint64_t actual; |
| 55 ASSERT_TRUE(reader.doReadUint64(&actual)); |
| 56 EXPECT_EQ(expected, actual); |
| 57 } |
| 58 |
46 } // namespace blink | 59 } // namespace blink |
OLD | NEW |