From 292f368fec42995efaa9d1c43e87aa1b96e86f83 Mon Sep 17 00:00:00 2001 From: Thomas Wilburn Date: Wed, 5 Sep 2018 16:35:07 -0500 Subject: [PATCH] Work around a hilariously bad enumeration bug --- map/map-test.js | 23 +++++++++++++++++++++++ test/test-define-only.js | 2 +- 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/map/map-test.js b/map/map-test.js index a7e892a..3e48cd0 100644 --- a/map/map-test.js +++ b/map/map-test.js @@ -1439,6 +1439,27 @@ QUnit.test("expandos use default type (#383)", function(){ }); QUnit.test("do not enumerate anything other than key properties (#369)", function(){ + // Internet Explorer doesn't correctly skip properties that are non-enumerable + // on the current object, but enumerable on the prototype: + var ancestor = { prop: true }; + var F = function() {}; + F.prototype = ancestor; + var descendant = new F(); + Object.defineProperty(descendant, "prop", { + writable: true, + configurable: true, + enumerable: false, + value: true + }); + var test = {}; + for (var k in descendant) test[k] = descendant[k]; + console.log(test); + debugger; + if (test.prop) { + return QUnit.ok(test.prop, "Browser doesn't correctly skip shadowed enumerable properties") + } + + var Type = DefineMap.extend({ aProp: "string", aMethod: function(){} @@ -1448,6 +1469,8 @@ QUnit.test("do not enumerate anything other than key properties (#369)", functio var props = {}; for(var prop in instance) { + var descriptor = Object.getOwnPropertyDescriptor(instance, prop); + if (!descriptor) descriptor = Object.getOwnPropertyDescriptor(Type.prototype, prop) || {}; props[prop] = true; } QUnit.deepEqual(props,{ diff --git a/test/test-define-only.js b/test/test-define-only.js index 6f71adb..415ea19 100644 --- a/test/test-define-only.js +++ b/test/test-define-only.js @@ -1246,7 +1246,7 @@ testHelpers.dev.devOnlyTest("warn on using a Constructor for small-t type defini testHelpers.dev.devOnlyTest("warn with constructor for Value instead of Default (#340)", function() { QUnit.expect(1); - var message = "can-define: Change the 'Value' definition for VM{}.currency to 'Default'."; + var message = /can-define: Change the 'Value' definition for [\w\.{}]+.currency to 'Default'./; var finishErrorCheck = testHelpers.dev.willWarn(message); function Currency() {