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

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

    XMLWordPrintable

Details

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

    Description

      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.

       

      Attachments

        1. Bug.qml
          0.2 kB
        2. lib.js
          0.9 kB

        Issue Links

          No reviews matched the request. Check your Options in the drop-down menu of this sections header.

          Activity

            People

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

              Dates

                Created:
                Updated:

                Gerrit Reviews

                  There are no open Gerrit changes