Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-66932

REGRESSION: Object.getOwnPropertyDescriptor returns wrong property descriptors for builtin objects

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Duplicate
    • Icon: P1: Critical P1: Critical
    • None
    • 5.10.1, 5.11.0 Alpha, 5.11.0 Beta 1
    • None

      E.g.:

      console.log(JSON.stringify(Object.getOwnPropertyDescriptor(Function.prototype, 'toString')));
      

      in Qt <= 5.9 prints correct:

      {"writable":true,"enumerable":false,"configurable":true}
      

      in Qt >= 5.10 prints wrong:

      {"writable":false,"enumerable":false,"configurable":false}
      

      Also:

      (function() {
          var funcToString = Function.prototype.toString;
          var funcLength = 'function'.length;
          Object.defineProperty(Function.prototype, 'toString', {
            value: function() {
                var ret = funcToString.call(this);
                if (this.name)
                    ret = ret.slice(0, funcLength) + ' ' + this.name + ret.slice(funcLength);
                return ret;
            },
            writable: true,
            enumerable: false,
            configurable: true
          });
      }())
      
      function foo() {
      }
      
      console.log(foo.toString());
      

      in <= 5.9 works as intended (adds name to function string), in >= 5.10 throws TypeError: Type error (this is wrong behavior).

       
      As the result, it is not possible to use any polyfill JS library inside QML JS engine, since all of them relies on modifying builtins functions.

       

        1. lib.js
          0.9 kB
        2. Bug.qml
          0.2 kB
        For Gerrit Dashboard: QTBUG-66932
        # Subject Branch Project Status CR V

            qtqmlteam Qt Qml Team User
            evg656e Evgeny
            Votes:
            1 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved:

                There are no open Gerrit changes