| Differences between
and this patch
- a/JavaScriptCore/ChangeLog +12 lines
Lines 1-3 a/JavaScriptCore/ChangeLog_sec1
1
2008-12-16  David Levin  <levin@chromium.org>
2
3
        Reviewed by NOBODY (OOPS!).
4
5
        https://bugs.webkit.org/show_bug.cgi?id=22720
6
        Add copy functionality to UString and expose it.
7
8
        * JavaScriptCore.exp:
9
        * runtime/UString.cpp:
10
        (JSC::UString::copy):
11
        * runtime/UString.h:
12
1
2008-12-15  Darin Adler  <darin@apple.com>
13
2008-12-15  Darin Adler  <darin@apple.com>
2
14
3
        * interpreter/RegisterFile.h: Tweak include formatting.
15
        * interpreter/RegisterFile.h: Tweak include formatting.
- a/JavaScriptCore/JavaScriptCore.exp +1 lines
Lines 334-339 __ZNK3JSC7JSValue7toFloatEPNS_9ExecStateE a/JavaScriptCore/JavaScriptCore.exp_sec1
334
__ZNK3JSC7JSValue9toIntegerEPNS_9ExecStateE
334
__ZNK3JSC7JSValue9toIntegerEPNS_9ExecStateE
335
__ZNK3JSC7UString10UTF8StringEb
335
__ZNK3JSC7UString10UTF8StringEb
336
__ZNK3JSC7UString14toStrictUInt32EPb
336
__ZNK3JSC7UString14toStrictUInt32EPb
337
__ZNK3JSC7UString4copyEv
337
__ZNK3JSC7UString5asciiEv
338
__ZNK3JSC7UString5asciiEv
338
__ZNK3JSC7UString6is8BitEv
339
__ZNK3JSC7UString6is8BitEv
339
__ZNK3JSC7UString6substrEii
340
__ZNK3JSC7UString6substrEii
- a/JavaScriptCore/runtime/UString.cpp +5 lines
Lines 542-547 UString::UString(const Vector<UChar>& buffer) a/JavaScriptCore/runtime/UString.cpp_sec1
542
        m_rep = Rep::createCopying(buffer.data(), buffer.size());
542
        m_rep = Rep::createCopying(buffer.data(), buffer.size());
543
}
543
}
544
544
545
UString UString::copy() const
546
{
547
    return UString(Rep::createCopying(data(), size()));
548
}
549
545
static ALWAYS_INLINE PassRefPtr<UString::Rep> concatenate(PassRefPtr<UString::Rep> r, const UChar* tData, int tSize)
550
static ALWAYS_INLINE PassRefPtr<UString::Rep> concatenate(PassRefPtr<UString::Rep> r, const UChar* tData, int tSize)
546
{
551
{
547
    RefPtr<UString::Rep> rep = r;
552
    RefPtr<UString::Rep> rep = r;
- a/JavaScriptCore/runtime/UString.h +4 lines
Lines 152-157 namespace JSC { a/JavaScriptCore/runtime/UString.h_sec1
152
        {
152
        {
153
        }
153
        }
154
154
155
        // Makes a deep copy. Helpful only if you need to use a UString on another thread.
156
        // Otherwise use UString(const UString&).
157
        UString copy() const;
158
155
        static UString from(int);
159
        static UString from(int);
156
        static UString from(unsigned int);
160
        static UString from(unsigned int);
157
        static UString from(long);
161
        static UString from(long);
- a/WebCore/ChangeLog +39 lines
Lines 1-3 a/WebCore/ChangeLog_sec1
1
2008-12-16  David Levin  <levin@chromium.org>
2
3
        Reviewed by NOBODY (OOPS!).
4
5
        https://bugs.webkit.org/show_bug.cgi?id=22720
6
        Move resourceRetrievedByXMLHttpRequest to ScriptExecutionContext.
7
        Add addMessageToConsole to ScriptExecutionContext.
8
        Use these methods from XMLHttpRequest.
9
10
        No observable change in behavior, so no test.
11
12
        * bindings/js/ScriptString.h:
13
        (WebCore::ScriptString::copy):
14
        * dom/Document.cpp:
15
        (WebCore::Document::addMessageToConsole):
16
        (WebCore::Document::resourceRetrievedByXMLHttpRequest):
17
        * dom/Document.h:
18
        * dom/ScriptExecutionContext.h:
19
        * dom/WorkerContext.cpp:
20
        (WebCore::WorkerContext::addMessageToConsole):
21
        (WebCore::WorkerContext::resourceRetrievedByXMLHttpRequest):
22
        * dom/WorkerContext.h:
23
        * dom/WorkerMessagingProxy.cpp:
24
        (WebCore::WorkerMessageToConsoleTask::create):
25
        (WebCore::WorkerMessageToConsoleTask::WorkerMessageToConsoleTask):
26
        (WebCore::WorkerMessageToConsoleTask::performTask):
27
        (WebCore::WorkerResourceRetrievedByXMLHttpRequestTask::create):
28
        (WebCore::WorkerResourceRetrievedByXMLHttpRequestTask::WorkerResourceRetrievedByXMLHttpRequestTask):
29
        (WebCore::WorkerResourceRetrievedByXMLHttpRequestTask::performTask):
30
        (WebCore::WorkerMessagingProxy::postMessageToConsole):
31
        (WebCore::WorkerMessagingProxy::postResourceRetrievedByXMLHttpRequest):
32
        * dom/WorkerMessagingProxy.h:
33
        * xml/XMLHttpRequest.cpp:
34
        (WebCore::reportUnsafeUsage):
35
        (WebCore::XMLHttpRequest::setRequestHeader):
36
        (WebCore::XMLHttpRequest::getResponseHeader):
37
        (WebCore::XMLHttpRequest::didFinishLoading):
38
        * xml/XMLHttpRequest.h:
39
1
2008-12-15  Sam Weinig  <sam@webkit.org>
40
2008-12-15  Sam Weinig  <sam@webkit.org>
2
41
3
        Reviewed by Darin Adler.
42
        Reviewed by Darin Adler.
- a/WebCore/bindings/js/ScriptString.h +7 lines
Lines 45-50 public: a/WebCore/bindings/js/ScriptString.h_sec1
45
    ScriptString(const char* s) : m_str(s) {}
45
    ScriptString(const char* s) : m_str(s) {}
46
    ScriptString(const JSC::UString& s) : m_str(s) {}
46
    ScriptString(const JSC::UString& s) : m_str(s) {}
47
47
48
    // Makes a deep copy. Helpful only if you need to use a ScriptString on another thread.
49
    // If you aren't using multiple threads, then use ScriptString(const JSC::UString&).
50
    ScriptString copy() const
51
    {
52
        return ScriptString(m_str.copy());
53
    }
54
48
    operator JSC::UString() const { return m_str; }
55
    operator JSC::UString() const { return m_str; }
49
56
50
    bool isNull() const { return m_str.isNull(); }
57
    bool isNull() const { return m_str.isNull(); }
- a/WebCore/dom/Document.cpp +16 lines
Lines 77-82 a/WebCore/dom/Document.cpp_sec1
77
#include "HitTestRequest.h"
77
#include "HitTestRequest.h"
78
#include "HitTestResult.h"
78
#include "HitTestResult.h"
79
#include "ImageLoader.h"
79
#include "ImageLoader.h"
80
#include "InspectorController.h"
80
#include "KeyboardEvent.h"
81
#include "KeyboardEvent.h"
81
#include "Logging.h"
82
#include "Logging.h"
82
#include "MessageEvent.h"
83
#include "MessageEvent.h"
Lines 4289-4294 void Document::reportException(const String& errorMessage, int lineNumber, const a/WebCore/dom/Document.cpp_sec2
4289
        window->console()->addMessage(JSMessageSource, ErrorMessageLevel, errorMessage, lineNumber, sourceURL);
4290
        window->console()->addMessage(JSMessageSource, ErrorMessageLevel, errorMessage, lineNumber, sourceURL);
4290
}
4291
}
4291
4292
4293
void Document::addMessageToConsole(MessageSource source, MessageLevel level, const String& message, unsigned lineNumber, const String& sourceURL, bool inspectorOnly)
4294
{
4295
    if (inspectorOnly) {
4296
        if (page())
4297
            page()->inspectorController()->addMessageToConsole(source, level, message, lineNumber, sourceURL);
4298
    } else if (DOMWindow* window = domWindow())
4299
        window->console()->addMessage(source, level, message, lineNumber, sourceURL);
4300
}
4301
4302
void Document::resourceRetrievedByXMLHttpRequest(unsigned long identifier, const ScriptString& sourceString)
4303
{
4304
    if (page())
4305
        page()->inspectorController()->resourceRetrievedByXMLHttpRequest(identifier, sourceString);
4306
}
4307
4292
class ScriptExecutionContextTaskTimer : public TimerBase {
4308
class ScriptExecutionContextTaskTimer : public TimerBase {
4293
public:
4309
public:
4294
    ScriptExecutionContextTaskTimer(PassRefPtr<Document> context, PassRefPtr<ScriptExecutionContext::Task> task)
4310
    ScriptExecutionContextTaskTimer(PassRefPtr<Document> context, PassRefPtr<ScriptExecutionContext::Task> task)
- a/WebCore/dom/Document.h +2 lines
Lines 776-781 public: a/WebCore/dom/Document.h_sec1
776
    void parseDNSPrefetchControlHeader(const String&);
776
    void parseDNSPrefetchControlHeader(const String&);
777
777
778
    virtual void reportException(const String& errorMessage, int lineNumber, const String& sourceURL);
778
    virtual void reportException(const String& errorMessage, int lineNumber, const String& sourceURL);
779
    virtual void addMessageToConsole(MessageSource, MessageLevel, const String& message, unsigned lineNumber, const String& sourceURL, bool inspectorOnly);
780
    virtual void resourceRetrievedByXMLHttpRequest(unsigned long identifier, const ScriptString& sourceString);
779
    virtual void postTask(PassRefPtr<Task>); // Executes the task on context's thread asynchronously.
781
    virtual void postTask(PassRefPtr<Task>); // Executes the task on context's thread asynchronously.
780
782
781
    void addTimeout(int timeoutId, DOMTimer*);
783
    void addTimeout(int timeoutId, DOMTimer*);
- a/WebCore/dom/ScriptExecutionContext.h +4 lines
Lines 27-32 a/WebCore/dom/ScriptExecutionContext.h_sec1
27
#ifndef ScriptExecutionContext_h
27
#ifndef ScriptExecutionContext_h
28
#define ScriptExecutionContext_h
28
#define ScriptExecutionContext_h
29
29
30
#include "Console.h"
30
#include <wtf/HashMap.h>
31
#include <wtf/HashMap.h>
31
#include <wtf/HashSet.h>
32
#include <wtf/HashSet.h>
32
#include <wtf/PassRefPtr.h>
33
#include <wtf/PassRefPtr.h>
Lines 37-42 namespace WebCore { a/WebCore/dom/ScriptExecutionContext.h_sec2
37
    class ActiveDOMObject;
38
    class ActiveDOMObject;
38
    class MessagePort;
39
    class MessagePort;
39
    class KURL;
40
    class KURL;
41
    class ScriptString;
40
    class SecurityOrigin;
42
    class SecurityOrigin;
41
    class String;
43
    class String;
42
44
Lines 53-58 namespace WebCore { a/WebCore/dom/ScriptExecutionContext.h_sec3
53
        SecurityOrigin* securityOrigin() const { return m_securityOrigin.get(); }
55
        SecurityOrigin* securityOrigin() const { return m_securityOrigin.get(); }
54
56
55
        virtual void reportException(const String& errorMessage, int lineNumber, const String& sourceURL) = 0;
57
        virtual void reportException(const String& errorMessage, int lineNumber, const String& sourceURL) = 0;
58
        virtual void addMessageToConsole(MessageSource, MessageLevel, const String& message, unsigned lineNumber, const String& sourceURL, bool inspectorOnly) = 0;
59
        virtual void resourceRetrievedByXMLHttpRequest(unsigned long identifier, const ScriptString& sourceString) = 0;
56
60
57
        // Active objects are not garbage collected even if inaccessible, e.g. because their activity may result in callbacks being invoked.
61
        // Active objects are not garbage collected even if inaccessible, e.g. because their activity may result in callbacks being invoked.
58
        bool canSuspendActiveDOMObjects();
62
        bool canSuspendActiveDOMObjects();
- a/WebCore/dom/WorkerContext.cpp +10 lines
Lines 104-109 void WorkerContext::reportException(const String& errorMessage, int lineNumber, a/WebCore/dom/WorkerContext.cpp_sec1
104
    m_thread->messagingProxy()->postWorkerException(errorMessage, lineNumber, sourceURL);
104
    m_thread->messagingProxy()->postWorkerException(errorMessage, lineNumber, sourceURL);
105
}
105
}
106
106
107
void WorkerContext::addMessageToConsole(MessageSource source, MessageLevel level, const String& message, unsigned lineNumber, const String& sourceURL, bool inspectorOnly)
108
{
109
    m_thread->messagingProxy()->postMessageToConsole(source, level, message, lineNumber, sourceURL, inspectorOnly);
110
}
111
112
void WorkerContext::resourceRetrievedByXMLHttpRequest(unsigned long identifier, const ScriptString& sourceString)
113
{
114
    m_thread->messagingProxy()->postResourceRetrievedByXMLHttpRequest(identifier, sourceString);
115
}
116
107
void WorkerContext::postMessage(const String& message)
117
void WorkerContext::postMessage(const String& message)
108
{
118
{
109
    m_thread->messagingProxy()->postMessageToWorkerObject(message);
119
    m_thread->messagingProxy()->postMessageToWorkerObject(message);
- a/WebCore/dom/WorkerContext.h +2 lines
Lines 73-78 namespace WebCore { a/WebCore/dom/WorkerContext.h_sec1
73
        bool hasPendingActivity() const;
73
        bool hasPendingActivity() const;
74
74
75
        virtual void reportException(const String& errorMessage, int lineNumber, const String& sourceURL);
75
        virtual void reportException(const String& errorMessage, int lineNumber, const String& sourceURL);
76
        virtual void addMessageToConsole(MessageSource, MessageLevel, const String& message, unsigned lineNumber, const String& sourceURL, bool inspectorOnly);
77
        virtual void resourceRetrievedByXMLHttpRequest(unsigned long identifier, const ScriptString& sourceString);
76
78
77
        virtual WorkerContext* toWorkerContext() { return this; }
79
        virtual WorkerContext* toWorkerContext() { return this; }
78
80
- a/WebCore/dom/WorkerMessagingProxy.cpp +76 lines
Lines 1-5 a/WebCore/dom/WorkerMessagingProxy.cpp_sec1
1
/*
1
/*
2
 * Copyright (C) 2008 Apple Inc. All Rights Reserved.
2
 * Copyright (C) 2008 Apple Inc. All Rights Reserved.
3
 * Copyright (C) 2008 David Levin (levin@chromium.org)
3
 *
4
 *
4
 * Redistribution and use in source and binary forms, with or without
5
 * Redistribution and use in source and binary forms, with or without
5
 * modification, are permitted provided that the following conditions
6
 * modification, are permitted provided that the following conditions
Lines 33-38 a/WebCore/dom/WorkerMessagingProxy.cpp_sec2
33
#include "DOMWindow.h"
34
#include "DOMWindow.h"
34
#include "Document.h"
35
#include "Document.h"
35
#include "MessageEvent.h"
36
#include "MessageEvent.h"
37
#include "ScriptString.h"
36
#include "Worker.h"
38
#include "Worker.h"
37
#include "WorkerContext.h"
39
#include "WorkerContext.h"
38
#include "WorkerTask.h"
40
#include "WorkerTask.h"
Lines 141-146 private: a/WebCore/dom/WorkerMessagingProxy.cpp_sec3
141
    WorkerMessagingProxy* m_messagingProxy;
143
    WorkerMessagingProxy* m_messagingProxy;
142
};
144
};
143
145
146
class WorkerMessageToConsoleTask : public ScriptExecutionContext::Task {
147
public:
148
    static PassRefPtr<WorkerMessageToConsoleTask> create(MessageSource source, MessageLevel level, const String& message, unsigned lineNumber, const String& sourceURL, bool inspectorOnly, WorkerMessagingProxy* messagingProxy)
149
    {
150
        return adoptRef(new WorkerMessageToConsoleTask(source, level, message, lineNumber, sourceURL, inspectorOnly, messagingProxy));
151
    }
152
153
private:
154
    WorkerMessageToConsoleTask(MessageSource source, MessageLevel level, const String& message, unsigned lineNumber, const String& sourceURL, bool inspectorOnly, WorkerMessagingProxy* messagingProxy)
155
        : m_source(source)
156
        , m_level(level)
157
        , m_message(message.copy())
158
        , m_lineNumber(lineNumber)
159
        , m_sourceURL(sourceURL.copy())
160
        , m_inspectorOnly(inspectorOnly)
161
        , m_messagingProxy(messagingProxy)
162
    {
163
    }
164
165
    virtual void performTask(ScriptExecutionContext* context)
166
    {
167
        if (m_messagingProxy->askedToTerminate())
168
            return;
169
        context->addMessageToConsole(m_source, m_level, m_message, m_lineNumber, m_sourceURL, m_inspectorOnly);
170
    }
171
172
private:
173
    MessageSource m_source;
174
    MessageLevel m_level;
175
    String m_message;
176
    unsigned m_lineNumber;
177
    String m_sourceURL;
178
    bool m_inspectorOnly;
179
    WorkerMessagingProxy* m_messagingProxy;
180
};
181
182
class WorkerResourceRetrievedByXMLHttpRequestTask : public ScriptExecutionContext::Task {
183
public:
184
    static PassRefPtr<WorkerResourceRetrievedByXMLHttpRequestTask> create(unsigned long identifier, const ScriptString& sourceString, WorkerMessagingProxy* messagingProxy)
185
    {
186
        return adoptRef(new WorkerResourceRetrievedByXMLHttpRequestTask(identifier, sourceString, messagingProxy));
187
    }
188
189
private:
190
    WorkerResourceRetrievedByXMLHttpRequestTask(unsigned long identifier, const ScriptString& sourceString, WorkerMessagingProxy* messagingProxy)
191
        : m_identifier(identifier)
192
        , m_sourceString(sourceString.copy())
193
        , m_messagingProxy(messagingProxy)
194
    {
195
    }
196
197
    virtual void performTask(ScriptExecutionContext* context)
198
    {
199
        if (m_messagingProxy->askedToTerminate())
200
            return;
201
        context->resourceRetrievedByXMLHttpRequest(m_identifier, m_sourceString);
202
    }
203
204
private:
205
    unsigned long m_identifier;
206
    ScriptString m_sourceString;
207
    WorkerMessagingProxy* m_messagingProxy;
208
};
209
144
class WorkerContextDestroyedTask : public ScriptExecutionContext::Task {
210
class WorkerContextDestroyedTask : public ScriptExecutionContext::Task {
145
public:
211
public:
146
    static PassRefPtr<WorkerContextDestroyedTask> create(WorkerMessagingProxy* messagingProxy)
212
    static PassRefPtr<WorkerContextDestroyedTask> create(WorkerMessagingProxy* messagingProxy)
Lines 231-236 void WorkerMessagingProxy::postWorkerException(const String& errorMessage, int l a/WebCore/dom/WorkerMessagingProxy.cpp_sec4
231
    m_scriptExecutionContext->postTask(WorkerExceptionTask::create(errorMessage, lineNumber, sourceURL, this));
297
    m_scriptExecutionContext->postTask(WorkerExceptionTask::create(errorMessage, lineNumber, sourceURL, this));
232
}
298
}
233
299
300
void WorkerMessagingProxy::postMessageToConsole(MessageSource source, MessageLevel level, const String& message, unsigned lineNumber, const String& sourceURL, bool inspectorOnly)
301
{
302
    m_scriptExecutionContext->postTask(WorkerMessageToConsoleTask::create(source, level, message, lineNumber, sourceURL, inspectorOnly, this));
303
}
304
305
void WorkerMessagingProxy::postResourceRetrievedByXMLHttpRequest(unsigned long identifier, const ScriptString& sourceString)
306
{
307
    m_scriptExecutionContext->postTask(WorkerResourceRetrievedByXMLHttpRequestTask::create(identifier, sourceString, this));
308
}
309
234
void WorkerMessagingProxy::workerThreadCreated(PassRefPtr<WorkerThread> workerThread)
310
void WorkerMessagingProxy::workerThreadCreated(PassRefPtr<WorkerThread> workerThread)
235
{
311
{
236
    m_workerThread = workerThread;
312
    m_workerThread = workerThread;
- a/WebCore/dom/WorkerMessagingProxy.h +6 lines
Lines 29-34 a/WebCore/dom/WorkerMessagingProxy.h_sec1
29
29
30
#if ENABLE(WORKERS)
30
#if ENABLE(WORKERS)
31
31
32
#include "Console.h"
32
#include <wtf/Noncopyable.h>
33
#include <wtf/Noncopyable.h>
33
#include <wtf/PassRefPtr.h>
34
#include <wtf/PassRefPtr.h>
34
#include <wtf/RefPtr.h>
35
#include <wtf/RefPtr.h>
Lines 37-42 a/WebCore/dom/WorkerMessagingProxy.h_sec2
37
namespace WebCore {
38
namespace WebCore {
38
39
39
    class ScriptExecutionContext;
40
    class ScriptExecutionContext;
41
    class ScriptString;
40
    class String;
42
    class String;
41
    class Worker;
43
    class Worker;
42
    class WorkerTask;
44
    class WorkerTask;
Lines 50-55 namespace WebCore { a/WebCore/dom/WorkerMessagingProxy.h_sec3
50
        void postMessageToWorkerContext(const String& message);
52
        void postMessageToWorkerContext(const String& message);
51
53
52
        void postWorkerException(const String& errorMessage, int lineNumber, const String& sourceURL);
54
        void postWorkerException(const String& errorMessage, int lineNumber, const String& sourceURL);
55
        void postMessageToConsole(MessageSource, MessageLevel, const String& message, unsigned lineNumber, const String& sourceURL, bool inspectorOnly);
56
        void postResourceRetrievedByXMLHttpRequest(unsigned long identifier, const ScriptString& sourceString);
53
57
54
        void workerThreadCreated(PassRefPtr<WorkerThread>);
58
        void workerThreadCreated(PassRefPtr<WorkerThread>);
55
        void workerObjectDestroyed();
59
        void workerObjectDestroyed();
Lines 65-70 namespace WebCore { a/WebCore/dom/WorkerMessagingProxy.h_sec4
65
        friend class MessageWorkerTask;
69
        friend class MessageWorkerTask;
66
        friend class WorkerContextDestroyedTask;
70
        friend class WorkerContextDestroyedTask;
67
        friend class WorkerExceptionTask;
71
        friend class WorkerExceptionTask;
72
        friend class WorkerMessageToConsoleTask;
73
        friend class WorkerResourceRetrievedByXMLHttpRequestTask;
68
        friend class WorkerThreadActivityReportTask;
74
        friend class WorkerThreadActivityReportTask;
69
75
70
        ~WorkerMessagingProxy();
76
        ~WorkerMessagingProxy();
- a/WebCore/xml/XMLHttpRequest.cpp -16 / +9 lines
Lines 967-982 void XMLHttpRequest::overrideMimeType(const String& override) a/WebCore/xml/XMLHttpRequest.cpp_sec1
967
    m_mimeTypeOverride = override;
967
    m_mimeTypeOverride = override;
968
}
968
}
969
969
970
static void reportUnsafeUsage(Document* document, const String& message)
970
static void reportUnsafeUsage(ScriptExecutionContext* context, const String& message)
971
{
971
{
972
    if (!document)
972
    if (!context)
973
        return;
973
        return;
974
    Frame* frame = document->frame();
974
    // FIXME: It's not good to report the bad usage without indicating what source line it came from.
975
    if (!frame)
976
        return;
977
    // It's not good to report the bad usage without indicating what source line it came from.
978
    // We should pass additional parameters so we can tell the console where the mistake occurred.
975
    // We should pass additional parameters so we can tell the console where the mistake occurred.
979
    frame->domWindow()->console()->addMessage(JSMessageSource, ErrorMessageLevel, message, 1, String());
976
    context->addMessageToConsole(JSMessageSource, ErrorMessageLevel, message, 1, String(), false);
980
}
977
}
981
978
982
void XMLHttpRequest::setRequestHeader(const String& name, const String& value, ExceptionCode& ec)
979
void XMLHttpRequest::setRequestHeader(const String& name, const String& value, ExceptionCode& ec)
Lines 999-1005 void XMLHttpRequest::setRequestHeader(const String& name, const String& value, E a/WebCore/xml/XMLHttpRequest.cpp_sec2
999
996
1000
    // A privileged script (e.g. a Dashboard widget) can set any headers.
997
    // A privileged script (e.g. a Dashboard widget) can set any headers.
1001
    if (!scriptExecutionContext()->securityOrigin()->canLoadLocalResources() && !isSafeRequestHeader(name)) {
998
    if (!scriptExecutionContext()->securityOrigin()->canLoadLocalResources() && !isSafeRequestHeader(name)) {
1002
        reportUnsafeUsage(document(), "Refused to set unsafe header \"" + name + "\"");
999
        reportUnsafeUsage(scriptExecutionContext(), "Refused to set unsafe header \"" + name + "\"");
1003
        return;
1000
        return;
1004
    }
1001
    }
1005
1002
Lines 1070-1081 String XMLHttpRequest::getResponseHeader(const String& name, ExceptionCode& ec) a/WebCore/xml/XMLHttpRequest.cpp_sec3
1070
1067
1071
    // See comment in getAllResponseHeaders above.
1068
    // See comment in getAllResponseHeaders above.
1072
    if (isSetCookieHeader(name) && !scriptExecutionContext()->securityOrigin()->canLoadLocalResources()) {
1069
    if (isSetCookieHeader(name) && !scriptExecutionContext()->securityOrigin()->canLoadLocalResources()) {
1073
        reportUnsafeUsage(document(), "Refused to get unsafe header \"" + name + "\"");
1070
        reportUnsafeUsage(scriptExecutionContext(), "Refused to get unsafe header \"" + name + "\"");
1074
        return "";
1071
        return "";
1075
    }
1072
    }
1076
1073
1077
    if (!m_sameOriginRequest && !isOnAccessControlResponseHeaderWhitelist(name)) {
1074
    if (!m_sameOriginRequest && !isOnAccessControlResponseHeaderWhitelist(name)) {
1078
        reportUnsafeUsage(document(), "Refused to get unsafe header \"" + name + "\"");
1075
        reportUnsafeUsage(scriptExecutionContext(), "Refused to get unsafe header \"" + name + "\"");
1079
        return "";
1076
        return "";
1080
    }
1077
    }
1081
1078
Lines 1187-1198 void XMLHttpRequest::didFinishLoading(SubresourceLoader* loader) a/WebCore/xml/XMLHttpRequest.cpp_sec4
1187
    if (m_decoder)
1184
    if (m_decoder)
1188
        m_responseText += m_decoder->flush();
1185
        m_responseText += m_decoder->flush();
1189
1186
1190
    if (Frame* frame = document()->frame()) {
1187
    scriptExecutionContext()->resourceRetrievedByXMLHttpRequest(m_loader ? m_loader->identifier() : m_identifier, m_responseText);
1191
        if (Page* page = frame->page()) {
1188
    scriptExecutionContext()->addMessageToConsole(JSMessageSource, LogMessageLevel, "XHR finished loading: \"" + m_url + "\".", m_lastSendLineNumber, m_lastSendURL, true);
1192
            page->inspectorController()->resourceRetrievedByXMLHttpRequest(m_loader ? m_loader->identifier() : m_identifier, m_responseText);
1193
            page->inspectorController()->addMessageToConsole(JSMessageSource, LogMessageLevel, "XHR finished loading: \"" + m_url + "\".", m_lastSendLineNumber, m_lastSendURL);
1194
        }
1195
    }
1196
1189
1197
    bool hadLoader = m_loader;
1190
    bool hadLoader = m_loader;
1198
    m_loader = 0;
1191
    m_loader = 0;
- a/WebCore/xml/XMLHttpRequest.h -1 / +1 lines
Lines 26-33 a/WebCore/xml/XMLHttpRequest.h_sec1
26
#include "EventTarget.h"
26
#include "EventTarget.h"
27
#include "FormData.h"
27
#include "FormData.h"
28
#include "ResourceResponse.h"
28
#include "ResourceResponse.h"
29
#include "SubresourceLoaderClient.h"
30
#include "ScriptString.h"
29
#include "ScriptString.h"
30
#include "SubresourceLoaderClient.h"
31
#include <wtf/OwnPtr.h>
31
#include <wtf/OwnPtr.h>
32
32
33
namespace WebCore {
33
namespace WebCore {

Return to Bug 22720