Changeset 127426 in webkit


Ignore:
Timestamp:
Sep 3, 2012 9:09:54 AM (12 years ago)
Author:
commit-queue@webkit.org
Message:

Web Inspector: [WebGL] Make the injected resourceObject property non-enumerable
https://bugs.webkit.org/show_bug.cgi?id=95682

Patch by Andrey Adaikin <aandrey@chromium.org> on 2012-09-03
Reviewed by Pavel Feldman.

Make the injected auxiliary property resourceObject non-enumerable to hide it from for..in iterations.
Ideally this property should be completely hidden from the user's code.
Drive-by: Fix couple of small FIXME's.

  • inspector/InjectedScriptWebGLModuleSource.js:

(.):

Location:
trunk/Source/WebCore
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r127425 r127426  
     12012-09-03  Andrey Adaikin  <aandrey@chromium.org>
     2
     3        Web Inspector: [WebGL] Make the injected __resourceObject property non-enumerable
     4        https://bugs.webkit.org/show_bug.cgi?id=95682
     5
     6        Reviewed by Pavel Feldman.
     7
     8        Make the injected auxiliary property __resourceObject non-enumerable to hide it from for..in iterations.
     9        Ideally this property should be completely hidden from the user's code.
     10        Drive-by: Fix couple of small FIXME's.
     11
     12        * inspector/InjectedScriptWebGLModuleSource.js:
     13        (.):
     14
    1152012-09-03  Tommy Widenflycht  <tommyw@google.com>
    216
  • trunk/Source/WebCore/inspector/InjectedScriptWebGLModuleSource.js

    r127243 r127426  
    650650
    651651    /**
    652      * @param {Object} object
     652     * @param {!Object} object
    653653     */
    654654    _bindObjectToResource: function(object)
    655655    {
    656         object["__resourceObject"] = this;
     656        Object.defineProperty(object, "__resourceObject", {
     657            value: this,
     658            writable: false,
     659            enumerable: false,
     660            configurable: true
     661        });
    657662    }
    658663}
     
    14391444                    set: function(value)
    14401445                    {
     1446                        console.error("ASSERT_NOT_REACHED: We assume all WebGLRenderingContext attributes are readonly. Trying to mutate " + property);
    14411447                        gl[property] = value;
    14421448                    }
     
    14481454            processProperty(property);
    14491455
     1456        this._bindObjectToResource(proxy);
    14501457        return proxy;
    14511458    },
     
    18591866    wrapWebGLContext: function(glContext)
    18601867    {
    1861         var resource = Resource.forObject(glContext) || new WebGLRenderingContextResource(glContext, this._constructReplayContext.bind(this, glContext));
     1868        var resource = Resource.forObject(glContext) || new WebGLRenderingContextResource(glContext, this._constructWebGLReplayContext.bind(this, glContext));
    18621869        this._manager.registerResource(resource);
    18631870        var proxy = resource.proxyObject();
     
    19521959     * @return {WebGLRenderingContext}
    19531960     */
    1954     _constructReplayContext: function(originalGlContext)
     1961    _constructWebGLReplayContext: function(originalGlContext)
    19551962    {
    19561963        var replayContext = originalGlContext["__replayContext"];
    19571964        if (!replayContext) {
    19581965            var canvas = originalGlContext.canvas.cloneNode(true);
    1959             // FIXME: Pass original context id instead of "experimental-webgl".
    1960             // FIXME: Pass original ContextAttributes to the getContext() method.
    1961             replayContext = /** @type {WebGLRenderingContext} */ Resource.wrappedObject(canvas.getContext("experimental-webgl"));
    1962             originalGlContext["__replayContext"] = replayContext;
     1966            var attributes = originalGlContext.getContextAttributes();
     1967            var contextIds = ["experimental-webgl", "webkit-3d", "3d"];
     1968            for (var i = 0, contextId; contextId = contextIds[i]; ++i) {
     1969                replayContext = canvas.getContext(contextId, attributes);
     1970                if (replayContext) {
     1971                    replayContext = /** @type {WebGLRenderingContext} */ Resource.wrappedObject(replayContext);
     1972                    break;
     1973                }
     1974            }
     1975            Object.defineProperty(originalGlContext, "__replayContext", {
     1976                value: replayContext,
     1977                writable: false,
     1978                enumerable: false,
     1979                configurable: true
     1980            });
    19631981            this._replayContext = replayContext;
    19641982        } else {
Note: See TracChangeset for help on using the changeset viewer.