blob: 73611fb121f0c20f6cefff6260edd3da8c5afad4 [file] [log] [blame]
<!DOCTYPE html>
<html>
<head>
<script src="../../resources/js-test-pre.js"></script>
</head>
<body>
<script>
description('Check that custom accessor being redefined invalidates our inline caches.');
(function() {
"use strict";
let setterCalled = false;
function accessProperty() {
let oScript = document.createElement("script");
oScript.src = Math.random();
}
// Force "code optimization" by calling the function several times
for (let i = 0; i < 1000; i++) {
accessProperty();
}
// Define a custom setter for HTMLScriptElement#src
const descriptor = Object.getOwnPropertyDescriptor(HTMLScriptElement.prototype, "src");
Object.defineProperty(HTMLScriptElement.prototype, "src", {
get: descriptor.get,
set: function() {
setterCalled = true;
descriptor.set.apply(this, arguments);
},
enumerable: descriptor.enumerable,
configurable: descriptor.configurable
});
accessProperty();
if (setterCalled)
testPassed("setter called as expected");
else
testFailed("Unexpected, setter not called.");
})();
</script>
<script src="../../resources/js-test-post.js"></script>
</body>
</html>