Diff
Modified: trunk/LayoutTests/ChangeLog (201421 => 201422)
--- trunk/LayoutTests/ChangeLog 2016-05-26 17:08:17 UTC (rev 201421)
+++ trunk/LayoutTests/ChangeLog 2016-05-26 17:23:02 UTC (rev 201422)
@@ -1,3 +1,14 @@
+2016-05-26 Brady Eidson <[email protected]>
+
+ Implement internals.observeGC to get called back when a _javascript_ object is GC'ed.
+ https://bugs.webkit.org/show_bug.cgi?id=158093
+
+ Reviewed by Geoffrey Garen.
+
+ * js/script-tests/test-observegc.js: Added.
+ * js/test-observegc-expected.txt: Added.
+ * js/test-observegc.html: Added.
+
2016-05-26 Myles C. Maxfield <[email protected]>
[Font Loading] Allow empty strings in FontFace constructor
Added: trunk/LayoutTests/js/script-tests/test-observegc.js (0 => 201422)
--- trunk/LayoutTests/js/script-tests/test-observegc.js (rev 0)
+++ trunk/LayoutTests/js/script-tests/test-observegc.js 2016-05-26 17:23:02 UTC (rev 201422)
@@ -0,0 +1,9 @@
+description("Ensures that window.internals.observegc works as expected");
+
+var testObject = { testProperty : "testValue" };
+
+var observer = internals.observeGC(testObject);
+testObject = null;
+gc();
+
+shouldBe('observer.wasCollected', 'true');
Added: trunk/LayoutTests/js/test-observegc-expected.txt (0 => 201422)
--- trunk/LayoutTests/js/test-observegc-expected.txt (rev 0)
+++ trunk/LayoutTests/js/test-observegc-expected.txt 2016-05-26 17:23:02 UTC (rev 201422)
@@ -0,0 +1,10 @@
+Ensures that window.internals.observegc works as expected
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS observer.wasCollected is true
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
Added: trunk/LayoutTests/js/test-observegc.html (0 => 201422)
--- trunk/LayoutTests/js/test-observegc.html (rev 0)
+++ trunk/LayoutTests/js/test-observegc.html 2016-05-26 17:23:02 UTC (rev 201422)
@@ -0,0 +1,9 @@
+<html>
+<head>
+<script src=""
+</head>
+<body>
+<script src=""
+<script src=""
+</body>
+</html>
Modified: trunk/Source/WebCore/CMakeLists.txt (201421 => 201422)
--- trunk/Source/WebCore/CMakeLists.txt 2016-05-26 17:08:17 UTC (rev 201421)
+++ trunk/Source/WebCore/CMakeLists.txt 2016-05-26 17:23:02 UTC (rev 201422)
@@ -3408,6 +3408,7 @@
)
set(WebCoreTestSupport_IDL_FILES
+ testing/GCObservation.idl
testing/InternalSettings.idl
testing/Internals.idl
testing/MallocStatistics.idl
@@ -3426,6 +3427,7 @@
platform/mock/mediasource/MockSourceBufferPrivate.cpp
platform/mock/mediasource/MockTracks.cpp
+ testing/GCObservation.cpp
testing/InternalSettings.cpp
testing/Internals.cpp
testing/MockPageOverlay.cpp
Modified: trunk/Source/WebCore/ChangeLog (201421 => 201422)
--- trunk/Source/WebCore/ChangeLog 2016-05-26 17:08:17 UTC (rev 201421)
+++ trunk/Source/WebCore/ChangeLog 2016-05-26 17:23:02 UTC (rev 201422)
@@ -1,3 +1,26 @@
+2016-05-26 Brady Eidson <[email protected]>
+
+ Implement internals.observeGC to get called back when a _javascript_ object is GC'ed.
+ https://bugs.webkit.org/show_bug.cgi?id=158093
+
+ Reviewed by Geoffrey Garen.
+
+ Test: js/test-observegc.html
+
+ * CMakeLists.txt:
+ * DerivedSources.make:
+ * WebCore.xcodeproj/project.pbxproj:
+
+ * testing/GCObservation.cpp: Added.
+ (WebCore::GCObservation::GCObservation):
+ * testing/GCObservation.h: Added.
+ * testing/GCObservation.idl: Added.
+
+ * testing/Internals.cpp:
+ (WebCore::Internals::observeGC):
+ * testing/Internals.h:
+ * testing/Internals.idl:
+
2016-05-26 Myles C. Maxfield <[email protected]>
[Font Loading] Allow empty strings in FontFace constructor
Modified: trunk/Source/WebCore/DerivedSources.make (201421 => 201422)
--- trunk/Source/WebCore/DerivedSources.make 2016-05-26 17:08:17 UTC (rev 201421)
+++ trunk/Source/WebCore/DerivedSources.make 2016-05-26 17:23:02 UTC (rev 201422)
@@ -535,6 +535,7 @@
$(WebCore)/plugins/DOMPluginArray.idl \
$(WebCore)/storage/Storage.idl \
$(WebCore)/storage/StorageEvent.idl \
+ $(WebCore)/testing/GCObservation.idl \
$(WebCore)/testing/Internals.idl \
$(WebCore)/testing/InternalSettings.idl \
$(WebCore)/testing/MallocStatistics.idl \
Modified: trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj (201421 => 201422)
--- trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj 2016-05-26 17:08:17 UTC (rev 201421)
+++ trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj 2016-05-26 17:23:02 UTC (rev 201422)
@@ -2071,6 +2071,10 @@
517139071BF64DEF000D5F01 /* MemoryCursor.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 517139011BF64DE3000D5F01 /* MemoryCursor.cpp */; };
517139081BF64DEF000D5F01 /* MemoryCursor.h in Headers */ = {isa = PBXBuildFile; fileRef = 517139021BF64DE3000D5F01 /* MemoryCursor.h */; };
51714EA81CF4E4B1004723C4 /* IDBActiveDOMObject.h in Headers */ = {isa = PBXBuildFile; fileRef = 51714EA71CF4DE87004723C4 /* IDBActiveDOMObject.h */; settings = {ATTRIBUTES = (Private, ); }; };
+ 51714EAC1CF65951004723C4 /* GCObservation.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 51714EA91CF65899004723C4 /* GCObservation.cpp */; };
+ 51714EAD1CF65951004723C4 /* GCObservation.h in Headers */ = {isa = PBXBuildFile; fileRef = 51714EAA1CF65899004723C4 /* GCObservation.h */; };
+ 51714EB01CF665CE004723C4 /* JSGCObservation.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 51714EAE1CF6654A004723C4 /* JSGCObservation.cpp */; };
+ 51714EB11CF665CE004723C4 /* JSGCObservation.h in Headers */ = {isa = PBXBuildFile; fileRef = 51714EAF1CF6654A004723C4 /* JSGCObservation.h */; };
51741D0F0B07259A00ED442C /* BackForwardClient.h in Headers */ = {isa = PBXBuildFile; fileRef = 51741D0B0B07259A00ED442C /* BackForwardClient.h */; settings = {ATTRIBUTES = (Private, ); }; };
51741D110B07259A00ED442C /* HistoryItem.h in Headers */ = {isa = PBXBuildFile; fileRef = 51741D0D0B07259A00ED442C /* HistoryItem.h */; settings = {ATTRIBUTES = (Private, ); }; };
51741D120B07259A00ED442C /* HistoryItem.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 51741D0E0B07259A00ED442C /* HistoryItem.cpp */; };
@@ -9662,6 +9666,11 @@
517139031BF64DE3000D5F01 /* MemoryObjectStoreCursor.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = MemoryObjectStoreCursor.cpp; sourceTree = "<group>"; };
517139041BF64DE3000D5F01 /* MemoryObjectStoreCursor.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MemoryObjectStoreCursor.h; sourceTree = "<group>"; };
51714EA71CF4DE87004723C4 /* IDBActiveDOMObject.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = IDBActiveDOMObject.h; sourceTree = "<group>"; };
+ 51714EA91CF65899004723C4 /* GCObservation.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = GCObservation.cpp; sourceTree = "<group>"; };
+ 51714EAA1CF65899004723C4 /* GCObservation.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = GCObservation.h; sourceTree = "<group>"; };
+ 51714EAB1CF65899004723C4 /* GCObservation.idl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = GCObservation.idl; sourceTree = "<group>"; };
+ 51714EAE1CF6654A004723C4 /* JSGCObservation.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSGCObservation.cpp; sourceTree = "<group>"; };
+ 51714EAF1CF6654A004723C4 /* JSGCObservation.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSGCObservation.h; sourceTree = "<group>"; };
51741D0B0B07259A00ED442C /* BackForwardClient.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = BackForwardClient.h; sourceTree = "<group>"; };
51741D0D0B07259A00ED442C /* HistoryItem.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = HistoryItem.h; sourceTree = "<group>"; };
51741D0E0B07259A00ED442C /* HistoryItem.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = HistoryItem.cpp; sourceTree = "<group>"; };
@@ -16719,6 +16728,9 @@
isa = PBXGroup;
children = (
41815C1B138319630057AAA4 /* js */,
+ 51714EA91CF65899004723C4 /* GCObservation.cpp */,
+ 51714EAA1CF65899004723C4 /* GCObservation.h */,
+ 51714EAB1CF65899004723C4 /* GCObservation.idl */,
417DA4CF13734326007C57FB /* Internals.cpp */,
417DA4CE13734326007C57FB /* Internals.h */,
41813F9113818AD60057AAA4 /* Internals.idl */,
@@ -16752,6 +16764,8 @@
417DA71213735D90007C57FB /* Testing */ = {
isa = PBXGroup;
children = (
+ 51714EAE1CF6654A004723C4 /* JSGCObservation.cpp */,
+ 51714EAF1CF6654A004723C4 /* JSGCObservation.h */,
417DA71B13735DFA007C57FB /* JSInternals.cpp */,
417DA71C13735DFA007C57FB /* JSInternals.h */,
A7B4EA7814C9348400C8F5BF /* JSInternalSettings.cpp */,
@@ -24987,6 +25001,7 @@
A7BF7EE014C9175A0014489D /* InternalSettings.h in Headers */,
53E29E5F167A8A1900586D3D /* InternalSettingsGenerated.h in Headers */,
417DA71E13735DFA007C57FB /* JSInternals.h in Headers */,
+ 51714EB11CF665CE004723C4 /* JSGCObservation.h in Headers */,
A740B5A514C935AB00A77FA4 /* JSInternalSettings.h in Headers */,
53ED3FDF167A88E7006762E6 /* JSInternalSettingsGenerated.h in Headers */,
A740B59514C935AB00A77FA4 /* JSMallocStatistics.h in Headers */,
@@ -24996,6 +25011,7 @@
CDC26B41160A8CCE0026757B /* MockCDM.h in Headers */,
A1BF6B831AA96C7D00AF4A8A /* MockContentFilter.h in Headers */,
A1B5B29F1AAA846F008B6042 /* MockContentFilterSettings.h in Headers */,
+ 51714EAD1CF65951004723C4 /* GCObservation.h in Headers */,
2D6F3E911C1ECB2F0061DBD4 /* MockPageOverlay.h in Headers */,
2D97F04819DD4140001EE9C3 /* MockPageOverlayClient.h in Headers */,
AA5F3B8D16CC33D100455EB0 /* PlatformSpeechSynthesizerMock.h in Headers */,
@@ -28966,10 +28982,12 @@
53E29E5E167A8A1900586D3D /* InternalSettingsGenerated.cpp in Sources */,
417DA71D13735DFA007C57FB /* JSInternals.cpp in Sources */,
A740B5A714C935AF00A77FA4 /* JSInternalSettings.cpp in Sources */,
+ 51714EAC1CF65951004723C4 /* GCObservation.cpp in Sources */,
53ED3FDE167A88E7006762E6 /* JSInternalSettingsGenerated.cpp in Sources */,
A740B59714C935AF00A77FA4 /* JSMallocStatistics.cpp in Sources */,
CD5393D3175E018600C07123 /* JSMemoryInfo.cpp in Sources */,
A19AEA221AAA808A00B52B25 /* JSMockContentFilterSettings.cpp in Sources */,
+ 51714EB01CF665CE004723C4 /* JSGCObservation.cpp in Sources */,
A1E5B31F1AAD1DA4006EBEFB /* JSMockContentFilterSettingsCustom.cpp in Sources */,
2D4150DE1C1F868C000A3BA2 /* JSMockPageOverlay.cpp in Sources */,
EBF5121C1696496C0056BD25 /* JSTypeConversions.cpp in Sources */,
Added: trunk/Source/WebCore/testing/GCObservation.cpp (0 => 201422)
--- trunk/Source/WebCore/testing/GCObservation.cpp (rev 0)
+++ trunk/Source/WebCore/testing/GCObservation.cpp 2016-05-26 17:23:02 UTC (rev 201422)
@@ -0,0 +1,36 @@
+/*
+ * Copyright (C) 2016 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "GCObservation.h"
+
+namespace WebCore {
+
+GCObservation::GCObservation(JSC::JSObject* object)
+ : m_observedValue(object, nullptr, nullptr)
+{
+}
+
+} // namespace WebCore
Added: trunk/Source/WebCore/testing/GCObservation.h (0 => 201422)
--- trunk/Source/WebCore/testing/GCObservation.h (rev 0)
+++ trunk/Source/WebCore/testing/GCObservation.h 2016-05-26 17:23:02 UTC (rev 201422)
@@ -0,0 +1,51 @@
+/*
+ * Copyright (C) 2016 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#pragma once
+
+#include <heap/Weak.h>
+#include <runtime/JSCJSValueInlines.h>
+#include <runtime/JSObject.h>
+#include <wtf/RefCounted.h>
+#include <wtf/RefPtr.h>
+
+namespace WebCore {
+
+class GCObservation final : public RefCounted<GCObservation> {
+public:
+ template<typename... Args> static RefPtr<GCObservation> create(Args&&... args)
+ {
+ return adoptRef(new GCObservation(std::forward<Args>(args)...));
+ }
+
+ bool wasCollected() const { return !m_observedValue; }
+
+private:
+ explicit GCObservation(JSC::JSObject*);
+
+ mutable JSC::Weak<JSC::JSObject> m_observedValue;
+};
+
+} // namespace WebCore
Added: trunk/Source/WebCore/testing/GCObservation.idl (0 => 201422)
--- trunk/Source/WebCore/testing/GCObservation.idl (rev 0)
+++ trunk/Source/WebCore/testing/GCObservation.idl 2016-05-26 17:23:02 UTC (rev 201422)
@@ -0,0 +1,38 @@
+/*
+ * Copyright (C) 2013 Google Inc. All rights reserved.
+ * Copyright (C) 2016 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ * * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+[
+ NoInterfaceObject,
+ ImplementationLacksVTable,
+ ExportMacro=WEBCORE_TESTSUPPORT_EXPORT,
+] interface GCObservation {
+ readonly attribute boolean wasCollected;
+};
Modified: trunk/Source/WebCore/testing/Internals.cpp (201421 => 201422)
--- trunk/Source/WebCore/testing/Internals.cpp 2016-05-26 17:08:17 UTC (rev 201421)
+++ trunk/Source/WebCore/testing/Internals.cpp 2016-05-26 17:23:02 UTC (rev 201422)
@@ -59,6 +59,7 @@
#include "FormController.h"
#include "FrameLoader.h"
#include "FrameView.h"
+#include "GCObservation.h"
#include "HTMLCanvasElement.h"
#include "HTMLIFrameElement.h"
#include "HTMLImageElement.h"
@@ -3321,4 +3322,12 @@
return UserGestureIndicator::processingUserGesture();
}
+RefPtr<GCObservation> Internals::observeGC(JSC::JSValue value)
+{
+ if (!value || value.isNull() || value.isUndefined() || !value.getObject())
+ return nullptr;
+
+ return GCObservation::create(value.getObject());
}
+
+} // namespace WebCore
Modified: trunk/Source/WebCore/testing/Internals.h (201421 => 201422)
--- trunk/Source/WebCore/testing/Internals.h 2016-05-26 17:08:17 UTC (rev 201421)
+++ trunk/Source/WebCore/testing/Internals.h 2016-05-26 17:23:02 UTC (rev 201422)
@@ -46,6 +46,7 @@
class Element;
class File;
class Frame;
+class GCObservation;
class HTMLImageElement;
class HTMLInputElement;
class HTMLLinkElement;
@@ -482,6 +483,8 @@
bool isProcessingUserGesture();
+ RefPtr<GCObservation> observeGC(JSC::JSValue);
+
private:
explicit Internals(Document&);
Document* contextDocument() const;
Modified: trunk/Source/WebCore/testing/Internals.idl (201421 => 201422)
--- trunk/Source/WebCore/testing/Internals.idl 2016-05-26 17:08:17 UTC (rev 201421)
+++ trunk/Source/WebCore/testing/Internals.idl 2016-05-26 17:23:02 UTC (rev 201422)
@@ -455,4 +455,6 @@
void setResourceTimingSupport(boolean scalable);
boolean isProcessingUserGesture();
+
+ GCObservation observeGC(any observed);
};