Simplify idltest
authorMarkus Lanthaler <mark_lanthaler@gmx.net>
Wed, 10 Apr 2013 12:08:49 +0200
changeset 1583 21ed5714ea8e
parent 1582 6ebd6c358c91
child 1584 1ffff52a9b05
Simplify idltest
test-suite/idltest/index.html
--- a/test-suite/idltest/index.html	Wed Apr 10 10:39:53 2013 +0200
+++ b/test-suite/idltest/index.html	Wed Apr 10 12:08:49 2013 +0200
@@ -99,32 +99,33 @@
 <script>
 
 (function() {
-  window.JsonLdProcessor = window.jsonld.JsonLdProcessor;
-  window.processor = new JsonLdProcessor();
-
-  // pass writable/enumerable tests
-  if(Object.defineProperty) {
+  // setup JsonLdProcessor
+  if (Object.defineProperty) {
+    Object.defineProperty(window, 'JsonLdProcessor', {
+      writable: true,
+      enumerable: false,
+      configurable: true,
+      value: window.jsonld.JsonLdProcessor
+    });
     Object.defineProperty(JsonLdProcessor, 'prototype', {
       writable: false,
       enumerable: false
     });
-    Object.defineProperty(window, 'JsonLdProcessor', {
-      writable: true,
-      enumerable: false
-    });
   }
 
-  // pass stringification tests
+  // Ensure that stringification tests are passed
   var toString = Object.prototype.toString;
   Object.prototype.toString = function() {
-    if(this === window.JsonLdProcessor.prototype) {
+    if (this === window.JsonLdProcessor.prototype) {
       return '[object JsonLdProcessorPrototype]';
+    } else if (this.constructor === window.JsonLdProcessor) {
+      return '[object JsonLdProcessor]';
     }
-    if(this === window.processor) {
-      return window.processor.toString();
-    }
+
     return toString.apply(this, arguments);
-  };
+  }
+
+  window.processor = new JsonLdProcessor();
 
   var idl_array = new IdlArray();
 
@@ -141,3 +142,4 @@
 
 </body>
 </html>
+