OLD | NEW |
1 function expectBufferValue(bytesPerElement, expectedValues, buffer) { | 1 function expectBufferValue(bytesPerElement, expectedValues, buffer) { |
2 expectedBufferValues = expectedValues; | 2 expectedBufferValues = expectedValues; |
3 var arrayClass; | 3 var arrayClass; |
4 if (bytesPerElement == 1) | 4 if (bytesPerElement == 1) |
5 arrayClass = Uint8Array; | 5 arrayClass = Uint8Array; |
6 else | 6 else |
7 arrayClass = Uint16Array; | 7 arrayClass = Uint16Array; |
8 bufferView = new arrayClass(buffer); | 8 bufferView = new arrayClass(buffer); |
9 shouldBe("bufferView.length", "expectedBufferValues.length"); | 9 shouldBe("bufferView.length", "expectedBufferValues.length"); |
10 var success = (bufferView.length == expectedBufferValues.length); | 10 var success = (bufferView.length == expectedBufferValues.length); |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
86 return; | 86 return; |
87 } else { | 87 } else { |
88 self.thrownException = e; | 88 self.thrownException = e; |
89 self.expectedException = serializeExceptionValue; | 89 self.expectedException = serializeExceptionValue; |
90 shouldBe("thrownException.code", "expectedException"); | 90 shouldBe("thrownException.code", "expectedException"); |
91 return; | 91 return; |
92 } | 92 } |
93 } | 93 } |
94 expectBufferValue(bytesPerElement, values, serialized); | 94 expectBufferValue(bytesPerElement, values, serialized); |
95 } | 95 } |
| 96 |
| 97 function testBlobSerialization() { |
| 98 debug(""); |
| 99 self.blobObj1 = new Blob(['Hi'], {type: 'text/plain'}); |
| 100 self.blobObj2 = internals.deserializeBuffer(internals.serializeObject(blobOb
j1)); |
| 101 shouldBeTrue("areValuesIdentical(blobObj1, blobObj2)"); |
| 102 self.dictionaryWithBlob1 = {blob: blobObj1, string: 'stringValue'}; |
| 103 self.dictionaryWithBlob2 = internals.deserializeBuffer(internals.serializeOb
ject(dictionaryWithBlob1)); |
| 104 shouldBeTrue("areValuesIdentical(dictionaryWithBlob1, dictionaryWithBlob2)")
; |
| 105 |
| 106 // Compare contents too. |
| 107 var xhr1 = new XMLHttpRequest(); |
| 108 xhr1.open("GET", URL.createObjectURL(self.blobObj1), false); |
| 109 xhr1.send(); |
| 110 self.blobContent1 = xhr1.response; |
| 111 var xhr2 = new XMLHttpRequest(); |
| 112 xhr2.open("GET", URL.createObjectURL(self.blobObj2), false); |
| 113 xhr2.send(); |
| 114 self.blobContent2 = xhr2.response; |
| 115 shouldBe("self.blobContent1", "self.blobContent2"); |
| 116 } |
OLD | NEW |