summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/html/infrastructure/safe-passing-of-structured-data/shared-array-buffers/resources/test-sab.js
blob: 6d6efda00db263f7ba86f80ad94744a0777f6ea9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
"use strict";

self.assertSABsHaveSameBackingBlock = (originalSAB, clonedSAB) => {
  const originalView = new Uint8Array(originalSAB);
  const clonedView = new Uint8Array(clonedSAB);

  assert_not_equals(originalSAB, clonedSAB, "the clone must not be the same object");

  assert_equals(originalView[0], 0, "originalView[0] starts 0");
  assert_equals(clonedView[0], 0, "clonedView[0] starts 0");

  originalView[0] = 5;
  assert_equals(originalView[0], 5, "originalView[0] ends up 5");
  assert_equals(clonedView[0], 5, "clonedView[0] ends up 5");
};