Changeset 136534 in webkit


Ignore:
Timestamp:
Dec 4, 2012 11:04:38 AM (11 years ago)
Author:
yurys@chromium.org
Message:

Web Inspector: Can't take a heap snapshot in chromium ("Uncaught ReferenceError")
https://bugs.webkit.org/show_bug.cgi?id=103997

Reviewed by Pavel Feldman.

utilities.js used in both page and worker contexts should not access window
object as there is no one in case of workers. NonLeakingMutationObserver implementation
has moved to DOMExtension.js

  • inspector/front-end/DOMExtension.js:

(NonLeakingMutationObserver.NonLeakingMutationObserver._unloadListener):
(NonLeakingMutationObserver):
(NonLeakingMutationObserver.prototype.observe):
(NonLeakingMutationObserver.prototype.disconnect):

  • inspector/front-end/utilities.js:
Location:
trunk/Source/WebCore
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r136531 r136534  
     12012-12-04  Yury Semikhatsky  <yurys@chromium.org>
     2
     3        Web Inspector: Can't take a heap snapshot in chromium ("Uncaught ReferenceError")
     4        https://bugs.webkit.org/show_bug.cgi?id=103997
     5
     6        Reviewed by Pavel Feldman.
     7
     8        utilities.js used in both page and worker contexts should not access window
     9        object as there is no one in case of workers. NonLeakingMutationObserver implementation
     10        has moved to DOMExtension.js
     11
     12        * inspector/front-end/DOMExtension.js:
     13        (NonLeakingMutationObserver.NonLeakingMutationObserver._unloadListener):
     14        (NonLeakingMutationObserver):
     15        (NonLeakingMutationObserver.prototype.observe):
     16        (NonLeakingMutationObserver.prototype.disconnect):
     17        * inspector/front-end/utilities.js:
     18
    1192012-12-04  Sheriff Bot  <webkit.review.bot@gmail.com>
    220
  • trunk/Source/WebCore/inspector/front-end/DOMExtension.js

    r136145 r136534  
    548548    e.consume();
    549549}
     550
     551window.isUnderTest = false;
     552
     553/**
     554 * Mutation observers leak memory. Keep track of them and disconnect
     555 * on unload.
     556 * @constructor
     557 * @param {function(Array.<WebKitMutation>)} handler
     558 */
     559function NonLeakingMutationObserver(handler)
     560{
     561    this._observer = new WebKitMutationObserver(handler);
     562    NonLeakingMutationObserver._instances.push(this);
     563    if (!window.testRunner && !window.isUnderTest && !NonLeakingMutationObserver._unloadListener) {
     564        NonLeakingMutationObserver._unloadListener = function() {
     565            while (NonLeakingMutationObserver._instances.length)
     566                NonLeakingMutationObserver._instances[NonLeakingMutationObserver._instances.length - 1].disconnect();
     567        };
     568        window.addEventListener("unload", NonLeakingMutationObserver._unloadListener, false);
     569    }
     570}
     571
     572NonLeakingMutationObserver._instances = [];
     573
     574NonLeakingMutationObserver.prototype = {
     575    /**
     576     * @param {Element} element
     577     * @param {Object} config
     578     */
     579    observe: function(element, config)
     580    {
     581        if (this._observer)
     582            this._observer.observe(element, config);
     583    },
     584
     585    disconnect: function()
     586    {
     587        if (this._observer)
     588            this._observer.disconnect();
     589        NonLeakingMutationObserver._instances.remove(this);
     590        delete this._observer;
     591    }
     592}
     593
  • trunk/Source/WebCore/inspector/front-end/utilities.js

    r136144 r136534  
    861861    window.eval(xhr.responseText + "\n//@ sourceURL=" + scriptName);
    862862}
    863 
    864 window.isUnderTest = false;
    865 
    866 /**
    867  * Mutation observers leak memory. Keep track of them and disconnect
    868  * on unload.
    869  * @constructor
    870  * @param {function(Array.<WebKitMutation>)} handler
    871  */
    872 function NonLeakingMutationObserver(handler)
    873 {
    874     this._observer = new WebKitMutationObserver(handler);
    875     NonLeakingMutationObserver._instances.push(this);
    876     if (!window.testRunner && !window.isUnderTest && !NonLeakingMutationObserver._unloadListener) {
    877         NonLeakingMutationObserver._unloadListener = function() {
    878             while (NonLeakingMutationObserver._instances.length)
    879                 NonLeakingMutationObserver._instances[NonLeakingMutationObserver._instances.length - 1].disconnect();
    880         };
    881         window.addEventListener("unload", NonLeakingMutationObserver._unloadListener, false);
    882     }
    883 }
    884 
    885 NonLeakingMutationObserver._instances = [];
    886 
    887 NonLeakingMutationObserver.prototype = {
    888     /**
    889      * @param {Element} element
    890      * @param {Object} config
    891      */
    892     observe: function(element, config)
    893     {
    894         if (this._observer)
    895             this._observer.observe(element, config);
    896     },
    897 
    898     disconnect: function()
    899     {
    900         if (this._observer)
    901             this._observer.disconnect();
    902         NonLeakingMutationObserver._instances.remove(this);
    903         delete this._observer;
    904     }
    905 }
    906 
Note: See TracChangeset for help on using the changeset viewer.