[SCM] WebKit Debian packaging branch, webkit-1.1, updated. upstream/1.1.15.1-1414-gc69ee75
jam at chromium.org
jam at chromium.org
Thu Oct 29 20:31:37 UTC 2009
The following commit has been merged in the webkit-1.1 branch:
commit 9e5f0f8fb25941fb89d8fc398cfc66acb44f9714
Author: jam at chromium.org <jam at chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date: Tue Sep 22 00:19:42 2009 +0000
WebCore:
2009-09-15 John Abd-El-Malek <jam at chromium.org>
Reviewed by Darin Fisher.
Prevent sleeps in unload handlers.
https://bugs.webkit.org/show_bug.cgi?id=29193
Test: fast/dom/Window/slow_unload_handler.html
* WebCore.gypi:
* bindings/v8/DateExtension.cpp: Added.
(WebCore::DateExtension::DateExtension):
(WebCore::DateExtension::get):
(WebCore::DateExtension::setAllowSleep):
(WebCore::DateExtension::GetNativeFunction):
(WebCore::DateExtension::weakCallback):
(WebCore::DateExtension::GiveEnableSleepDetectionFunction):
(WebCore::DateExtension::OnSleepDetected):
* bindings/v8/DateExtension.h: Added.
* bindings/v8/V8AbstractEventListener.cpp:
(WebCore::V8AbstractEventListener::invokeEventHandler):
* bindings/v8/V8Proxy.cpp:
(WebCore::V8Proxy::createNewContext):
(WebCore::V8Proxy::registerExtensionWithV8):
(WebCore::V8Proxy::registeredExtensionWithV8):
* bindings/v8/V8Proxy.h:
LayoutTests:
2009-09-15 John Abd-El-Malek <jam at chromium.org>
Reviewed by Darin Fisher.
Prevent sleeps in unload handlers.
https://bugs.webkit.org/show_bug.cgi?id=29193
* fast/dom/Window/resources/slow_unload_handler1.html: Added.
* fast/dom/Window/slow_unload_handler-expected.txt: Added.
* fast/dom/Window/slow_unload_handler.html: Added.
* platform/gtk/Skipped:
* platform/mac/Skipped:
* platform/qt/Skipped:
* platform/win/Skipped:
git-svn-id: http://svn.webkit.org/repository/webkit/trunk@48612 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/LayoutTests/ChangeLog b/LayoutTests/ChangeLog
index e804864..d6422db 100644
--- a/LayoutTests/ChangeLog
+++ b/LayoutTests/ChangeLog
@@ -1,3 +1,18 @@
+2009-09-15 John Abd-El-Malek <jam at chromium.org>
+
+ Reviewed by Darin Fisher.
+
+ Prevent sleeps in unload handlers.
+ https://bugs.webkit.org/show_bug.cgi?id=29193
+
+ * fast/dom/Window/resources/slow_unload_handler1.html: Added.
+ * fast/dom/Window/slow_unload_handler-expected.txt: Added.
+ * fast/dom/Window/slow_unload_handler.html: Added.
+ * platform/gtk/Skipped:
+ * platform/mac/Skipped:
+ * platform/qt/Skipped:
+ * platform/win/Skipped:
+
2009-09-21 Simon Fraser <simon.fraser at apple.com>
Reviewed by Dan Bernstein.
diff --git a/LayoutTests/fast/dom/Window/resources/slow_unload_handler1.html b/LayoutTests/fast/dom/Window/resources/slow_unload_handler1.html
new file mode 100644
index 0000000..6b84e30
--- /dev/null
+++ b/LayoutTests/fast/dom/Window/resources/slow_unload_handler1.html
@@ -0,0 +1,18 @@
+<html>
+<script>
+function pause(milliseconds) {
+ var now = new Date();
+ var exitTime = now.getTime() + milliseconds;
+ while (true) {
+ now = new Date();
+ if (now.getTime() > exitTime)
+ break;
+ }
+ parent.document.getElementById("results").appendChild(document.createTextNode("FAIL"));
+ if (layoutTestController)
+ layoutTestController.notifyDone();
+}
+</script>
+<body onunload="pause(10000);">
+</body>
+</html>
\ No newline at end of file
diff --git a/LayoutTests/fast/dom/Window/slow_unload_handler-expected.txt b/LayoutTests/fast/dom/Window/slow_unload_handler-expected.txt
new file mode 100644
index 0000000..f01dbd7
--- /dev/null
+++ b/LayoutTests/fast/dom/Window/slow_unload_handler-expected.txt
@@ -0,0 +1,6 @@
+frame "theiframe" - has 1 onunload handler(s)
+This is a test for bug 29193: Need to prevent Javascript sleeps in unload handlers. If successful, PASS should be printed below.
+
+PASS
+
+
diff --git a/LayoutTests/fast/dom/Window/slow_unload_handler.html b/LayoutTests/fast/dom/Window/slow_unload_handler.html
new file mode 100644
index 0000000..812358f
--- /dev/null
+++ b/LayoutTests/fast/dom/Window/slow_unload_handler.html
@@ -0,0 +1,34 @@
+<html>
+<head>
+<link rel="stylesheet" href="../../js/resources/js-test-style.css">
+<script>
+
+if (layoutTestController) {
+ layoutTestController.waitUntilDone();
+ layoutTestController.dumpAsText();
+}
+
+function done()
+{
+ if (document.getElementById("results").innerHTML == "")
+ document.getElementById("results").appendChild(document.createTextNode("PASS"));
+ if (layoutTestController)
+ layoutTestController.notifyDone();
+}
+
+function loaded() {
+ setTimeout("done()", 0);
+ document.getElementById("theiframe").outerHTML='';
+}
+
+</script>
+</head>
+<body onload="setTimeout('loaded();', 0)">
+<p>
+ This is a test for <a href="https://bugs.webkit.org/show_bug.cgi?id=29193">bug 29193</a>:
+ <i>Need to prevent Javascript sleeps in unload handlers.</i> If successful, PASS should be printed below.
+</p>
+<p id="results" class="pass"></p>
+<iframe id="theiframe" style="border: 0" src="resources/slow_unload_handler1.html">
+</body>
+</html>
\ No newline at end of file
diff --git a/LayoutTests/platform/gtk/Skipped b/LayoutTests/platform/gtk/Skipped
index bb0df82..e3cba49 100644
--- a/LayoutTests/platform/gtk/Skipped
+++ b/LayoutTests/platform/gtk/Skipped
@@ -5730,3 +5730,6 @@ http/tests/xmlhttprequest/workers/shared-worker-methods-async.html
# No authentication challenge handling
http/tests/loading/basic-credentials-sent-automatically.html
+
+# This port doesn't support detecting slow unload handlers.
+fast/dom/Window/slow_unload_handler.html
diff --git a/LayoutTests/platform/mac/Skipped b/LayoutTests/platform/mac/Skipped
index 078a17a..b89ae7d 100644
--- a/LayoutTests/platform/mac/Skipped
+++ b/LayoutTests/platform/mac/Skipped
@@ -108,3 +108,5 @@ media/video-controls-zoomed.html
# <rdar://problem/7196485> and https://bugs.webkit.org/show_bug.cgi?id=29021
fast/loader/frames-with-unload-handlers-in-page-cache.html
+# This port doesn't support detecting slow unload handlers.
+fast/dom/Window/slow_unload_handler.html
diff --git a/LayoutTests/platform/qt/Skipped b/LayoutTests/platform/qt/Skipped
index 2355229..4c03db5 100644
--- a/LayoutTests/platform/qt/Skipped
+++ b/LayoutTests/platform/qt/Skipped
@@ -4851,3 +4851,6 @@ userscripts
# No authentication challenge handling
http/tests/loading/basic-credentials-sent-automatically.html
+
+# This port doesn't support detecting slow unload handlers.
+fast/dom/Window/slow_unload_handler.html
diff --git a/LayoutTests/platform/win/Skipped b/LayoutTests/platform/win/Skipped
index bfa582a..0df8820 100644
--- a/LayoutTests/platform/win/Skipped
+++ b/LayoutTests/platform/win/Skipped
@@ -683,3 +683,6 @@ plugins/destroy-during-npp-new.html
# <https://bugs.webkit.org/show_bug.cgi?id=29353>
http/tests/xmlhttprequest/xmlhttprequest-missing-file-exception.html
+
+# This port doesn't support detecting slow unload handlers.
+fast/dom/Window/slow_unload_handler.html
\ No newline at end of file
diff --git a/WebCore/ChangeLog b/WebCore/ChangeLog
index 3fdd939..9b758b6 100644
--- a/WebCore/ChangeLog
+++ b/WebCore/ChangeLog
@@ -1,3 +1,30 @@
+2009-09-15 John Abd-El-Malek <jam at chromium.org>
+
+ Reviewed by Darin Fisher.
+
+ Prevent sleeps in unload handlers.
+ https://bugs.webkit.org/show_bug.cgi?id=29193
+
+ Test: fast/dom/Window/slow_unload_handler.html
+
+ * WebCore.gypi:
+ * bindings/v8/DateExtension.cpp: Added.
+ (WebCore::DateExtension::DateExtension):
+ (WebCore::DateExtension::get):
+ (WebCore::DateExtension::setAllowSleep):
+ (WebCore::DateExtension::GetNativeFunction):
+ (WebCore::DateExtension::weakCallback):
+ (WebCore::DateExtension::GiveEnableSleepDetectionFunction):
+ (WebCore::DateExtension::OnSleepDetected):
+ * bindings/v8/DateExtension.h: Added.
+ * bindings/v8/V8AbstractEventListener.cpp:
+ (WebCore::V8AbstractEventListener::invokeEventHandler):
+ * bindings/v8/V8Proxy.cpp:
+ (WebCore::V8Proxy::createNewContext):
+ (WebCore::V8Proxy::registerExtensionWithV8):
+ (WebCore::V8Proxy::registeredExtensionWithV8):
+ * bindings/v8/V8Proxy.h:
+
2009-09-21 Jian Li <jianli at chromium.org>
Reviewed by David Levin.
diff --git a/WebCore/WebCore.gypi b/WebCore/WebCore.gypi
index 996564c..198b8d5 100644
--- a/WebCore/WebCore.gypi
+++ b/WebCore/WebCore.gypi
@@ -690,6 +690,8 @@
'bindings/v8/custom/V8XMLSerializerConstructor.cpp',
'bindings/v8/custom/V8XPathEvaluatorConstructor.cpp',
'bindings/v8/custom/V8XSLTProcessorCustom.cpp',
+ 'bindings/v8/DateExtension.cpp',
+ 'bindings/v8/DateExtension.h',
'bindings/v8/DOMData.cpp',
'bindings/v8/DOMData.h',
'bindings/v8/DOMDataStore.cpp',
diff --git a/WebCore/bindings/v8/DateExtension.cpp b/WebCore/bindings/v8/DateExtension.cpp
new file mode 100644
index 0000000..9e25695
--- /dev/null
+++ b/WebCore/bindings/v8/DateExtension.cpp
@@ -0,0 +1,132 @@
+/*
+ * Copyright (C) 2009 Google 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.
+ */
+
+#include "config.h"
+#include "DateExtension.h"
+
+#include "V8Proxy.h"
+
+namespace WebCore {
+
+DateExtension* DateExtension::extension;
+
+static const char* dateExtensionName = "v8/DateExtension";
+static const char* dateExtensionScript =
+ "(function () {"
+ " var counter;"
+ " var orig_getTime;"
+ " function getTimeOverride() {"
+ " if (++counter > 1000)"
+ " OnSleepDetected();"
+ " return orig_getTime.call(this);"
+ " };"
+ " function enableSleepDetection(enable) {"
+ " if (enable) {"
+ " counter = 0;"
+ " orig_getTime = Date.prototype.getTime;"
+ " Date.prototype.getTime = getTimeOverride;"
+ " } else {"
+ " Date.prototype.getTime = orig_getTime;"
+ " }"
+ " };"
+ " native function OnSleepDetected();"
+ " native function GiveEnableSleepDetectionFunction();"
+ " GiveEnableSleepDetectionFunction(enableSleepDetection);"
+ "})()";
+
+DateExtension::DateExtension() : v8::Extension(dateExtensionName, dateExtensionScript)
+{
+}
+
+DateExtension* DateExtension::get()
+{
+ if (!extension)
+ extension = new DateExtension();
+ return extension;
+}
+
+void DateExtension::setAllowSleep(bool allow)
+{
+ v8::Handle<v8::Value> argv[1];
+ argv[0] = v8::String::New(allow ? "false" : "true");
+ for (size_t i = 0; i < callEnableSleepDetectionFunctionPointers.size(); ++i)
+ callEnableSleepDetectionFunctionPointers[i]->Call(v8::Object::New(), 1, argv);
+}
+
+v8::Handle<v8::FunctionTemplate> DateExtension::GetNativeFunction(v8::Handle<v8::String> name)
+{
+ if (name->Equals(v8::String::New("GiveEnableSleepDetectionFunction")))
+ return v8::FunctionTemplate::New(GiveEnableSleepDetectionFunction);
+ if (name->Equals(v8::String::New("OnSleepDetected")))
+ return v8::FunctionTemplate::New(OnSleepDetected);
+
+ return v8::Handle<v8::FunctionTemplate>();
+}
+
+void DateExtension::weakCallback(v8::Persistent<v8::Value> object, void* param)
+{
+ DateExtension* extension = get();
+ for (size_t i = 0; i < extension->callEnableSleepDetectionFunctionPointers.size(); ++i) {
+ if (extension->callEnableSleepDetectionFunctionPointers[i] == object) {
+ object.Dispose();
+ extension->callEnableSleepDetectionFunctionPointers.remove(i);
+ return;
+ }
+ }
+ ASSERT_NOT_REACHED();
+}
+
+v8::Handle<v8::Value> DateExtension::GiveEnableSleepDetectionFunction(const v8::Arguments& args)
+{
+ if (args.Length() != 1 || !args[0]->IsFunction())
+ return v8::Undefined();
+
+ // Ideally, we would get the Frame* here and associate it with the function pointer, so that
+ // each time we go into an unload handler we just call that frame's function. However there's
+ // no way to get the Frame* at this point, so we just store all the function pointers and call
+ // them all each time.
+ DateExtension* extension = get();
+ extension->callEnableSleepDetectionFunctionPointers.append(
+ v8::Persistent<v8::Function>::New(v8::Handle<v8::Function>::Cast(args[0])));
+ extension->callEnableSleepDetectionFunctionPointers.last().MakeWeak(NULL, weakCallback);
+ return v8::Undefined();
+}
+
+v8::Handle<v8::Value> DateExtension::OnSleepDetected(const v8::Arguments&)
+{
+ // After we call TerminateExecution(), we can't call back into JavaScript again, so
+ // reset all the other frames first.
+ get()->setAllowSleep(true);
+
+ v8::V8::TerminateExecution();
+ return v8::Undefined();
+}
+
+} // namespace WebCore
diff --git a/WebCore/bindings/v8/DateExtension.h b/WebCore/bindings/v8/DateExtension.h
new file mode 100644
index 0000000..6611c5b
--- /dev/null
+++ b/WebCore/bindings/v8/DateExtension.h
@@ -0,0 +1,61 @@
+/*
+ * Copyright (C) 2009 Google 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.
+ */
+
+#ifndef DateExtension_h
+#define DateExtension_h
+
+#include <v8.h>
+
+#include "Vector.h"
+
+namespace WebCore {
+
+// Prevent "sleep" calls in unload handlers.
+class DateExtension : public v8::Extension {
+public:
+ static DateExtension* get();
+ void setAllowSleep(bool allow);
+
+private:
+ DateExtension();
+ virtual v8::Handle<v8::FunctionTemplate> GetNativeFunction(v8::Handle<v8::String>);
+ static v8::Handle<v8::Value> GiveEnableSleepDetectionFunction(const v8::Arguments&);
+ static v8::Handle<v8::Value> OnSleepDetected(const v8::Arguments&);
+ static void weakCallback(v8::Persistent<v8::Value> object, void* param);
+
+ typedef WTF::Vector<v8::Persistent<v8::Function> > FunctionPointers;
+ FunctionPointers callEnableSleepDetectionFunctionPointers;
+
+ static DateExtension* extension;
+};
+
+} // namespace WebCore
+
+#endif // DateExtension_h
diff --git a/WebCore/bindings/v8/V8AbstractEventListener.cpp b/WebCore/bindings/v8/V8AbstractEventListener.cpp
index c0efea5..83d7e23 100644
--- a/WebCore/bindings/v8/V8AbstractEventListener.cpp
+++ b/WebCore/bindings/v8/V8AbstractEventListener.cpp
@@ -31,6 +31,7 @@
#include "config.h"
#include "V8AbstractEventListener.h"
+#include "DateExtension.h"
#include "Document.h"
#include "Event.h"
#include "Frame.h"
@@ -68,6 +69,10 @@ void V8AbstractEventListener::invokeEventHandler(v8::Handle<v8::Context> v8Conte
v8::Local<v8::String> eventSymbol = v8::String::NewSymbol("event");
v8::Local<v8::Value> returnValue;
+ // In beforeunload/unload handlers, we want to avoid sleeps which do tight loops of calling Date.getTime().
+ if (event->type() == "beforeunload" || event->type() == "unload")
+ DateExtension::get()->setAllowSleep(false);
+
{
// Catch exceptions thrown in the event handler so they do not propagate to javascript code that caused the event to fire.
v8::TryCatch tryCatch;
@@ -84,6 +89,8 @@ void V8AbstractEventListener::invokeEventHandler(v8::Handle<v8::Context> v8Conte
// Call the event handler.
tryCatch.SetVerbose(false); // We do not want to report the exception to the inspector console.
returnValue = callListenerFunction(jsEvent, event, isWindowEvent);
+ if (!tryCatch.CanContinue())
+ return;
// If an error occurs while handling the event, it should be reported.
if (tryCatch.HasCaught()) {
@@ -100,6 +107,9 @@ void V8AbstractEventListener::invokeEventHandler(v8::Handle<v8::Context> v8Conte
tryCatch.Reset();
}
+ if (event->type() == "beforeunload" || event->type() == "unload")
+ DateExtension::get()->setAllowSleep(true);
+
ASSERT(!V8Proxy::handleOutOfMemory() || returnValue.IsEmpty());
if (returnValue.IsEmpty())
diff --git a/WebCore/bindings/v8/V8Proxy.cpp b/WebCore/bindings/v8/V8Proxy.cpp
index 26822d0..4fb0f68 100644
--- a/WebCore/bindings/v8/V8Proxy.cpp
+++ b/WebCore/bindings/v8/V8Proxy.cpp
@@ -33,6 +33,7 @@
#include "ChromiumBridge.h"
#include "CSSMutableStyleDeclaration.h"
+#include "DateExtension.h"
#include "DOMObjectsInclude.h"
#include "DocumentLoader.h"
#include "FrameLoaderClient.h"
@@ -64,7 +65,7 @@ namespace WebCore {
v8::Persistent<v8::Context> V8Proxy::m_utilityContext;
// Static list of registered extensions
-V8ExtensionList V8Proxy::m_extensions;
+V8Extensions V8Proxy::m_extensions;
const char* V8Proxy::kContextDebugDataType = "type";
const char* V8Proxy::kContextDebugDataValue = "value";
@@ -904,20 +905,24 @@ v8::Persistent<v8::Context> V8Proxy::createNewContext(v8::Handle<v8::Object> glo
// Install a security handler with V8.
globalTemplate->SetAccessCheckCallbacks(V8Custom::v8DOMWindowNamedSecurityCheck, V8Custom::v8DOMWindowIndexedSecurityCheck, v8::Integer::New(V8ClassIndex::DOMWINDOW));
+ // Used to avoid sleep calls in unload handlers.
+ if (!registeredExtensionWithV8(DateExtension::get()))
+ registerExtension(DateExtension::get(), String());
+
// Dynamically tell v8 about our extensions now.
OwnArrayPtr<const char*> extensionNames(new const char*[m_extensions.size()]);
int index = 0;
- for (V8ExtensionList::iterator it = m_extensions.begin(); it != m_extensions.end(); ++it) {
- if (it->group && it->group != extensionGroup)
+ for (size_t i = 0; i < m_extensions.size(); ++i) {
+ if (m_extensions[i].group && m_extensions[i].group != extensionGroup)
continue;
// Note: we check the loader URL here instead of the document URL
// because we might be currently loading an URL into a blank page.
// See http://code.google.com/p/chromium/issues/detail?id=10924
- if (it->scheme.length() > 0 && (it->scheme != m_frame->loader()->activeDocumentLoader()->url().protocol() || it->scheme != m_frame->page()->mainFrame()->loader()->activeDocumentLoader()->url().protocol()))
+ if (m_extensions[i].scheme.length() > 0 && (m_extensions[i].scheme != m_frame->loader()->activeDocumentLoader()->url().protocol() || m_extensions[i].scheme != m_frame->page()->mainFrame()->loader()->activeDocumentLoader()->url().protocol()))
continue;
- extensionNames[index++] = it->extension->name();
+ extensionNames[index++] = m_extensions[i].extension->name();
}
v8::ExtensionConfiguration extensions(index, extensionNames.get());
result = v8::Context::New(&extensions, globalTemplate, global);
@@ -1253,28 +1258,35 @@ String V8Proxy::sourceName()
return toWebCoreString(v8::Debug::Call(frameSourceName));
}
-void V8Proxy::registerExtensionWithV8(v8::Extension* extension) {
+void V8Proxy::registerExtensionWithV8(v8::Extension* extension)
+{
// If the extension exists in our list, it was already registered with V8.
- for (V8ExtensionList::iterator it = m_extensions.begin(); it != m_extensions.end(); ++it) {
- if (it->extension == extension)
- return;
+ if (!registeredExtensionWithV8(extension))
+ v8::RegisterExtension(extension);
+}
+
+bool V8Proxy::registeredExtensionWithV8(v8::Extension* extension)
+{
+ for (size_t i = 0; i < m_extensions.size(); ++i) {
+ if (m_extensions[i].extension == extension)
+ return true;
}
- v8::RegisterExtension(extension);
+ return false;
}
void V8Proxy::registerExtension(v8::Extension* extension, const String& schemeRestriction)
{
registerExtensionWithV8(extension);
V8ExtensionInfo info = {schemeRestriction, 0, extension};
- m_extensions.push_back(info);
+ m_extensions.append(info);
}
void V8Proxy::registerExtension(v8::Extension* extension, int extensionGroup)
{
registerExtensionWithV8(extension);
V8ExtensionInfo info = {String(), extensionGroup, extension};
- m_extensions.push_back(info);
+ m_extensions.append(info);
}
bool V8Proxy::setContextDebugId(int debugId)
diff --git a/WebCore/bindings/v8/V8Proxy.h b/WebCore/bindings/v8/V8Proxy.h
index f266b78..8ca9520 100644
--- a/WebCore/bindings/v8/V8Proxy.h
+++ b/WebCore/bindings/v8/V8Proxy.h
@@ -39,7 +39,6 @@
#include "V8EventListenerList.h"
#include "V8GCController.h"
#include "V8Index.h"
-#include <list>
#include <v8.h>
#include <wtf/PassRefPtr.h> // so generated bindings don't have to
#include <wtf/Vector.h>
@@ -105,7 +104,7 @@ namespace WebCore {
int group;
v8::Extension* extension;
};
- typedef std::list<V8ExtensionInfo> V8ExtensionList;
+ typedef WTF::Vector<V8ExtensionInfo> V8Extensions;
class V8Proxy {
public:
@@ -381,6 +380,7 @@ namespace WebCore {
v8::Local<v8::Object> createWrapperFromCacheSlowCase(V8ClassIndex::V8WrapperType);
static void registerExtensionWithV8(v8::Extension*);
+ static bool registeredExtensionWithV8(v8::Extension*);
Frame* m_frame;
@@ -421,8 +421,8 @@ namespace WebCore {
// excessive recursion in the binding layer.
int m_recursion;
- // List of extensions registered with the context.
- static V8ExtensionList m_extensions;
+ // All of the extensions registered with the context.
+ static V8Extensions m_extensions;
};
template <int tag, typename T>
--
WebKit Debian packaging
More information about the Pkg-webkit-commits
mailing list