Skip to content

Commit

Permalink
Updates
Browse files Browse the repository at this point in the history
  • Loading branch information
sydp committed Apr 13, 2024
1 parent 8e5b831 commit b3ce4fd
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 12 deletions.
12 changes: 9 additions & 3 deletions dfindexeddb/indexeddb/chromium/blink.py
Original file line number Diff line number Diff line change
Expand Up @@ -280,6 +280,11 @@ class ImageBitmapTransfer(BaseIndex):
"""A Javascript ImageBitmapTransfer."""


@dataclass
class MediaSourceHandle(BaseIndex):
"""A Javascript MediaSourceHandle."""


@dataclass
class MessagePort(BaseIndex):
"""A Javascript MessagePort."""
Expand Down Expand Up @@ -765,7 +770,7 @@ def _ReadRTCEncodedAudioFrame(self) -> RTCEncodedAudioFrame:
_, index = self.deserializer.decoder.DecodeUint32Varint()
return RTCEncodedAudioFrame(index=index)

def _ReadRTCEncodedVideoFrame(self) -> RTCEncodedAudioFrame:
def _ReadRTCEncodedVideoFrame(self) -> RTCEncodedVideoFrame:
"""Reads a RTC Encoded Video Frame from the current position."""
_, index = self.deserializer.decoder.DecodeUint32Varint()
return RTCEncodedVideoFrame(index=index)
Expand Down Expand Up @@ -852,9 +857,10 @@ def _ReadRestrictionTarget(self):
"""Reads the restriction target from the current position."""
raise NotImplementedError('V8ScriptValueDecoder._ReadRestrictionTarget')

def _ReadMediaSourceHandle(self):
def _ReadMediaSourceHandle(self) -> MediaSourceHandle:
"""Reads the media source handle from the current position."""
raise NotImplementedError('V8ScriptValueDecoder._ReadMediaSourceHandle')
_, index = self.deserializer.decoder.DecodeUint32Varint()
return MediaSourceHandle(index=index)

def _ReadFencedFrameConfig(self):
"""Reads the fenced frame target from the current position."""
Expand Down
19 changes: 10 additions & 9 deletions tests/dfindexeddb/indexeddb/chromium/blink.py
Original file line number Diff line number Diff line change
Expand Up @@ -149,8 +149,8 @@ def test_ReadImageBitmap(self):
"""Tests Blink ImageBitmap decoding."""
with self.assertRaisesRegex(NotImplementedError, 'ReadImageBitmap'):
serialized_value = bytes([
0xff, 0x09, 0x3f, 0x00, 0x67, 0x01, 0x01, 0x02, 0x01,
0x08, 0x00, 0x00, 0xff, 0xff, 0x00, 0xff, 0x00, 0xff])
0xff, 0x09, 0x3f, 0x00, 0x67, 0x01, 0x01, 0x02, 0x01,
0x08, 0x00, 0x00, 0xff, 0xff, 0x00, 0xff, 0x00, 0xff])
_ = blink.V8ScriptValueDecoder.FromBytes(serialized_value)

def test_ReadImageBitmapTransfer(self):
Expand All @@ -165,7 +165,7 @@ def test_ReadImageData(self):
"""Tests Blink ImageData decoding."""
with self.assertRaisesRegex(NotImplementedError, 'ReadImageData'):
serialized_value = bytes([
0xff, 0x09, 0x3f, 0x00, 0x23, 0x00])
0xff, 0x09, 0x3f, 0x00, 0x23, 0x00])
_ = blink.V8ScriptValueDecoder.FromBytes(serialized_value)

def test_ReadDOMPoint(self):
Expand Down Expand Up @@ -647,28 +647,29 @@ def test_ReadCropTarget(self):
"""Tests CropTarget decoding."""
with self.assertRaisesRegex(NotImplementedError, 'ReadCropTarget'):
serialized_value = bytes([
0xff, 0x11, 0xff, 0x0d, 0x5c, 0x63, 0x00])
0xff, 0x11, 0xff, 0x0d, 0x5c, 0x63, 0x00])
_ = blink.V8ScriptValueDecoder.FromBytes(serialized_value)

def test_ReadRestrictionTarget(self):
"""Tests RestrictionTarget decoding."""
with self.assertRaisesRegex(NotImplementedError, 'ReadRestrictionTarget'):
serialized_value = bytes([
0xff, 0x11, 0xff, 0x0d, 0x5c, 0x44, 0x00])
0xff, 0x11, 0xff, 0x0d, 0x5c, 0x44, 0x00])
_ = blink.V8ScriptValueDecoder.FromBytes(serialized_value)

def test_ReadMediaSourceHandle(self):
"""Tests MediaSourceHandle decoding."""
with self.assertRaisesRegex(NotImplementedError, 'ReadMediaSourceHandle'):
serialized_value = bytes([
serialized_value = bytes([
0xff, 0x11, 0xff, 0x0d, 0x5c, 0x53, 0x00])
_ = blink.V8ScriptValueDecoder.FromBytes(serialized_value)
expected_value = blink.MediaSourceHandle(index=0)
parsed_value = blink.V8ScriptValueDecoder.FromBytes(serialized_value)
self.assertEqual(parsed_value, expected_value)

def test_ReadFencedFrameConfig(self):
"""Tests FencedFrameConfig decoding."""
with self.assertRaisesRegex(NotImplementedError, 'ReadFencedFrameConfig'):
serialized_value = bytes([
0xff, 0x11, 0xff, 0x0d, 0x5c, 0x43, 0x00])
0xff, 0x11, 0xff, 0x0d, 0x5c, 0x43, 0x00])
_ = blink.V8ScriptValueDecoder.FromBytes(serialized_value)


Expand Down

0 comments on commit b3ce4fd

Please sign in to comment.