IntlHiddenInternals.js 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. //-------------------------------------------------------------------------------------------------------
  2. // Copyright (C) Microsoft. All rights reserved.
  3. // Licensed under the MIT license. See LICENSE.txt file in the project root for full license information.
  4. //-------------------------------------------------------------------------------------------------------
  5. var collatorExcludeList = [];
  6. var numberFormatExcludeList = [];
  7. var dateTimeFormatExcludeList = [];
  8. function testHiddenInternals(constructor, objType, excludeList) {
  9. var obj = new constructor();
  10. var properties = Object.getOwnPropertyNames(obj);
  11. if (properties.length == 0) return;
  12. var extraProperties = false;
  13. properties.forEach(function (prop) {
  14. if (excludeList.indexOf(prop) !== -1) return;
  15. if (prop.indexOf("__", 0) === -1) {
  16. WScript.Echo("Detected additional property '" + prop + "' on '" + objType + "', if property is expected update this test's exclude lists.");
  17. extraProperties = true;
  18. }
  19. });
  20. if (extraProperties) {
  21. WScript.Echo("Failed for '" + objType + "'!");
  22. }
  23. }
  24. testHiddenInternals(Intl.Collator, "Collator", collatorExcludeList);
  25. testHiddenInternals(Intl.NumberFormat, "NumberFormat", numberFormatExcludeList);
  26. testHiddenInternals(Intl.DateTimeFormat, "DateTimeFormat", dateTimeFormatExcludeList);
  27. if(Intl.hasOwnProperty("EngineInterface") === true){
  28. WScript.Echo("EngineInterface object is not hidden.");
  29. }
  30. WScript.Echo("Pass");