test-sab.js (552B)
1 "use strict"; 2 3 self.assertSABsHaveSameBackingBlock = (originalSAB, clonedSAB) => { 4 const originalView = new Uint8Array(originalSAB); 5 const clonedView = new Uint8Array(clonedSAB); 6 7 assert_not_equals(originalSAB, clonedSAB, "the clone must not be the same object"); 8 9 assert_equals(originalView[0], 0, "originalView[0] starts 0"); 10 assert_equals(clonedView[0], 0, "clonedView[0] starts 0"); 11 12 originalView[0] = 5; 13 assert_equals(originalView[0], 5, "originalView[0] ends up 5"); 14 assert_equals(clonedView[0], 5, "clonedView[0] ends up 5"); 15 };