From af991266d423d10fb946d8344bc079b02a36975a Mon Sep 17 00:00:00 2001 From: Maximilian Antoni Date: Fri, 27 Apr 2018 11:30:09 +0100 Subject: [PATCH] Add a failing test for #1695 --- test/sandbox-test.js | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/test/sandbox-test.js b/test/sandbox-test.js index 11744bf8d..158758a3a 100644 --- a/test/sandbox-test.js +++ b/test/sandbox-test.js @@ -463,6 +463,22 @@ describe("Sandbox", function () { assert.equals(object.property, existing); }); + it("should replace an inherited property", function () { + var replacement = "replacement"; + var existing = "existing"; + var object = Object.create({ + property: existing + }); + + this.sandbox.replace(object, "property", replacement); + + assert.equals(object.property, replacement); + + this.sandbox.restore(); + + assert.equals(object.property, existing); + }); + it("should refuse to replace a non-function with a function", function () { var sandbox = this.sandbox; var replacement = function () { return "replacement"; };