summaryrefslogtreecommitdiffstats
path: root/js/src/tests/test262/built-ins/Object/defineProperty/S15.2.3.6_A1.js
blob: e57b9345ff852e50da62b3d0069c9ab0745c456f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
// Copyright 2011 Google Inc.  All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.

/*---
info: |
    If a particular API exists (document.createElement, as happens to
    exist in a browser environment), check if the form objects it makes
    obey the constraints that even host objects must obey. In this
    case, that if defineProperty seems to have successfully installed a
    non-configurable getter, that it is still there.
es5id: 15.2.3.6_A1
description: Do getters on HTMLFormElements disappear?
---*/

function getter() {
  return 'gotten';
}

if (typeof document !== 'undefined' &&
  typeof document.createElement === 'function') {
  var f = document.createElement("form");
  var refused = false;
  try {
    Object.defineProperty(f, 'foo', {
      get: getter,
      set: void 0
    });
  } catch (err) {
    // A host object may refuse to install the getter
    refused = true;
  }
  if (!refused) {
    var desc = Object.getOwnPropertyDescriptor(f, 'foo');
    assert.sameValue(desc.get, getter, 'The value of desc.get is expected to equal the value of getter');
  }
}

reportCompare(0, 0);