https://github.com/web-platform-tests/wpt
Raw File
Tip revision: 1f30c5ea5fe1a75b8613726331a2b3c9ade10c2c authored by James Graham on 28 March 2014, 17:50:42 UTC
fixup! Again
Tip revision: 1f30c5e
stringifiers.js
// Tests <http://dev.w3.org/2006/webapi/WebIDL/#es-stringifier>.
function test_stringifier_attribute(aObject, aAttribute) {
  // Step 1.
  test(function() {
    [null, undefined].forEach(function(v) {
      assert_throws(new TypeError(), function() {
        aObject.toString.call(v);
      });
    });
  });

  // Step 2.
  test(function() {
    assert_false("Window" in window && aObject instanceof window.Window);
    [{}, window].forEach(function(v) {
      assert_throws(new TypeError(), function() {
        aObject.toString.call(v)
      });
    });
  });

  // Step 3.
  var test_error = { name: "test" };
  test(function() {
    Object.defineProperty(aObject, aAttribute, {
      configurable: true,
      get: function() { throw test_error; }
    });
    assert_throws(test_error, function() {
      aObject.toString();
    });
  });

  // Step 4.
  test(function() {
    Object.defineProperty(aObject, aAttribute, {
      configurable: true,
      value: { toString: function() { throw test_error; } }
    });
    assert_throws(test_error, function() {
      aObject.toString();
    });
  });
}
back to top