blob: 5a7e850472dece8e708317a5db6c3ec4d86f2883 [file] [log] [blame]
<!DOCTYPE html>
<html>
<head>
<script src="../../resources/testharness.js"></script>
<script src="../../resources/testharnessreport.js"></script>
</head>
<body>
<script>
const originalIterator = Object.getOwnPropertyDescriptor(Array.prototype, Symbol.iterator);
test(() => {
let callCount = 0;
let array = [2.0, 0.0, 0.0, 2.0, 10.0, 10.0];
Object.defineProperty(array, Symbol.iterator, {
get() {
++callCount;
return originalIterator.value;
}
});
let matrix = new DOMMatrix(array);
assert_equals(callCount, 1, "@@iterator must only be accessed once.");
assert_equals(matrix.toString(), "matrix(2, 0, 0, 2, 10, 10)", "DOMMatrix constructor should work correctly.");
}, "@@iterator should only be accessed once, tested via replacement of @@iterator on instance.");
test((t) => {
t.add_cleanup(() => {
Object.defineProperty(Array.prototype, Symbol.iterator, originalIterator);
});
let callCount = 0;
const array = [2.0, 0.0, 0.0, 2.0, 10.0, 10.0];
Object.defineProperty(Array.prototype, Symbol.iterator, {
get() {
++callCount;
return originalIterator.value;
}
});
let matrix = new DOMMatrix(array);
assert_equals(callCount, 1, "@@iterator must only be accessed once.");
assert_equals(matrix.toString(), "matrix(2, 0, 0, 2, 10, 10)", "DOMMatrix constructor should work correctly.");
}, "@@iterator should only be accessed once, tested via replacement of @@iterator on prototype.");
</script>
</body>
</html>