- Revision
- 157417
- Author
- [email protected]
- Date
- 2013-10-14 13:28:55 -0700 (Mon, 14 Oct 2013)
Log Message
window.crypto doesn't preserve custom properties
https://bugs.webkit.org/show_bug.cgi?id=122770
Reviewed by Mark Hahnenberg.
Source/WebCore:
Test: security/crypto-gc.html
Generate isReachableFromOpaqueRoots that makes Crypto live as long as the document
lives (because that's when it's observable through window object).
* page/Crypto.cpp:
(WebCore::Crypto::Crypto):
(WebCore::Crypto::~Crypto):
(WebCore::Crypto::document):
* page/Crypto.h:
(WebCore::Crypto::create):
Made Crypto a ContextDestructionObserver, so that it can report its document to bindings.
Removed ScriptWrappable, because it seems to have served no purpose in this class.
* page/Crypto.idl: Added GenerateIsReachable. Removed ImplementationLacksVTable,
because the class now has a vtable, and can be checked for bindings integrity.
* page/DOMWindow.cpp: (WebCore::DOMWindow::crypto): Pass a document when creating
crypto.
LayoutTests:
* security/crypto-gc-expected.txt: Added.
* security/crypto-gc.html: Added.
Modified Paths
Added Paths
Diff
Modified: trunk/LayoutTests/ChangeLog (157416 => 157417)
--- trunk/LayoutTests/ChangeLog 2013-10-14 20:11:51 UTC (rev 157416)
+++ trunk/LayoutTests/ChangeLog 2013-10-14 20:28:55 UTC (rev 157417)
@@ -1,3 +1,13 @@
+2013-10-14 Alexey Proskuryakov <[email protected]>
+
+ window.crypto doesn't preserve custom properties
+ https://bugs.webkit.org/show_bug.cgi?id=122770
+
+ Reviewed by Mark Hahnenberg.
+
+ * security/crypto-gc-expected.txt: Added.
+ * security/crypto-gc.html: Added.
+
2013-10-14 Hans Muller <[email protected]>
[CSS Shapes] Image valued shape-outside shapes should update the layout after the image has been loaded
Added: trunk/LayoutTests/security/crypto-gc-expected.txt (0 => 157417)
--- trunk/LayoutTests/security/crypto-gc-expected.txt (rev 0)
+++ trunk/LayoutTests/security/crypto-gc-expected.txt 2013-10-14 20:28:55 UTC (rev 157417)
@@ -0,0 +1,10 @@
+Test that window.crypto wrapper preserves custom properties.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS window.crypto.foo is "bar"
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
Property changes on: trunk/LayoutTests/security/crypto-gc-expected.txt
___________________________________________________________________
Added: svn:mime-type
Added: svn:eol-style
Added: trunk/LayoutTests/security/crypto-gc.html (0 => 157417)
--- trunk/LayoutTests/security/crypto-gc.html (rev 0)
+++ trunk/LayoutTests/security/crypto-gc.html 2013-10-14 20:28:55 UTC (rev 157417)
@@ -0,0 +1,38 @@
+<!DOCTYPE html>
+<html>
+<head>
+<meta charset="utf-8">
+<script src=""
+</head>
+<body>
+<script>
+
+description("Test that window.crypto wrapper preserves custom properties.");
+jsTestIsAsync = true;
+
+function startTest()
+{
+ window.crypto.foo = "bar";
+ gc();
+ setTimeout(continueTest, 10);
+}
+
+function continueTest()
+{
+ gc();
+ setTimeout(finishTest, 10);
+}
+
+function finishTest()
+{
+ gc();
+ shouldBe('window.crypto.foo', '"bar"');
+ finishJSTest();
+}
+
+window._onload_ = startTest;
+
+</script>
+<script src=""
+</body>
+</html>
Property changes on: trunk/LayoutTests/security/crypto-gc.html
___________________________________________________________________
Added: svn:mime-type
Modified: trunk/Source/WebCore/ChangeLog (157416 => 157417)
--- trunk/Source/WebCore/ChangeLog 2013-10-14 20:11:51 UTC (rev 157416)
+++ trunk/Source/WebCore/ChangeLog 2013-10-14 20:28:55 UTC (rev 157417)
@@ -1,3 +1,30 @@
+2013-10-14 Alexey Proskuryakov <[email protected]>
+
+ window.crypto doesn't preserve custom properties
+ https://bugs.webkit.org/show_bug.cgi?id=122770
+
+ Reviewed by Mark Hahnenberg.
+
+ Test: security/crypto-gc.html
+
+ Generate isReachableFromOpaqueRoots that makes Crypto live as long as the document
+ lives (because that's when it's observable through window object).
+
+ * page/Crypto.cpp:
+ (WebCore::Crypto::Crypto):
+ (WebCore::Crypto::~Crypto):
+ (WebCore::Crypto::document):
+ * page/Crypto.h:
+ (WebCore::Crypto::create):
+ Made Crypto a ContextDestructionObserver, so that it can report its document to bindings.
+ Removed ScriptWrappable, because it seems to have served no purpose in this class.
+
+ * page/Crypto.idl: Added GenerateIsReachable. Removed ImplementationLacksVTable,
+ because the class now has a vtable, and can be checked for bindings integrity.
+
+ * page/DOMWindow.cpp: (WebCore::DOMWindow::crypto): Pass a document when creating
+ crypto.
+
2013-10-14 Andreas Kling <[email protected]>
CTTE: NamedNodeMap always has a corresponding Element.
Modified: trunk/Source/WebCore/page/Crypto.cpp (157416 => 157417)
--- trunk/Source/WebCore/page/Crypto.cpp 2013-10-14 20:11:51 UTC (rev 157416)
+++ trunk/Source/WebCore/page/Crypto.cpp 2013-10-14 20:28:55 UTC (rev 157417)
@@ -30,8 +30,8 @@
#include "config.h"
#include "Crypto.h"
+#include "Document.h"
#include "ExceptionCode.h"
-#include "ScriptWrappableInlines.h"
#include <runtime/ArrayBufferView.h>
#include <wtf/CryptographicallyRandomNumber.h>
@@ -46,10 +46,20 @@
}
-Crypto::Crypto()
+Crypto::Crypto(Document& document)
+ : ContextDestructionObserver(&document)
{
}
+Crypto::~Crypto()
+{
+}
+
+Document* Crypto::document() const
+{
+ return toDocument(scriptExecutionContext());
+}
+
void Crypto::getRandomValues(ArrayBufferView* array, ExceptionCode& ec)
{
if (!array || !isIntegerArray(array)) {
Modified: trunk/Source/WebCore/page/Crypto.h (157416 => 157417)
--- trunk/Source/WebCore/page/Crypto.h 2013-10-14 20:11:51 UTC (rev 157416)
+++ trunk/Source/WebCore/page/Crypto.h 2013-10-14 20:28:55 UTC (rev 157417)
@@ -29,7 +29,7 @@
#ifndef Crypto_h
#define Crypto_h
-#include "ScriptWrappable.h"
+#include "ContextDestructionObserver.h"
#include <wtf/Forward.h>
#include <wtf/PassRefPtr.h>
#include <wtf/RefCounted.h>
@@ -42,14 +42,19 @@
typedef int ExceptionCode;
-class Crypto : public ScriptWrappable, public RefCounted<Crypto> {
+class Document;
+
+class Crypto : public ContextDestructionObserver, public RefCounted<Crypto> {
public:
- static PassRefPtr<Crypto> create() { return adoptRef(new Crypto()); }
+ static PassRefPtr<Crypto> create(Document& document) { return adoptRef(new Crypto(document)); }
+ virtual ~Crypto();
+ Document* document() const;
+
void getRandomValues(JSC::ArrayBufferView*, ExceptionCode&);
private:
- Crypto();
+ Crypto(Document&);
};
}
Modified: trunk/Source/WebCore/page/Crypto.idl (157416 => 157417)
--- trunk/Source/WebCore/page/Crypto.idl 2013-10-14 20:11:51 UTC (rev 157416)
+++ trunk/Source/WebCore/page/Crypto.idl 2013-10-14 20:28:55 UTC (rev 157417)
@@ -28,7 +28,7 @@
[
NoInterfaceObject,
- ImplementationLacksVTable,
+ GenerateIsReachable=ImplDocument,
OperationsNotDeletable
] interface Crypto {
[Custom, RaisesException] ArrayBufferView getRandomValues(ArrayBufferView array);
Modified: trunk/Source/WebCore/page/DOMWindow.cpp (157416 => 157417)
--- trunk/Source/WebCore/page/DOMWindow.cpp 2013-10-14 20:11:51 UTC (rev 157416)
+++ trunk/Source/WebCore/page/DOMWindow.cpp 2013-10-14 20:28:55 UTC (rev 157417)
@@ -591,10 +591,11 @@
Crypto* DOMWindow::crypto() const
{
+ // FIXME: Why is crypto not available when the window is not currently displayed in a frame?
if (!isCurrentlyDisplayedInFrame())
return 0;
if (!m_crypto)
- m_crypto = Crypto::create();
+ m_crypto = Crypto::create(*document());
return m_crypto.get();
}