Changeset 258850 in webkit
- Timestamp:
- Mar 23, 2020 9:51:24 AM (4 years ago)
- Location:
- trunk
- Files:
-
- 13 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r258845 r258850 1 2020-03-23 Chris Dumez <cdumez@apple.com> 2 3 Port window.postMessage to the HTML event loop 4 https://bugs.webkit.org/show_bug.cgi?id=209359 5 6 Reviewed by Alex Christensen. 7 8 Update tests so that it does not run postMessage tests in parallel on the 2 different-origin iframes, 9 since the ordering would not be guaranteed and it would cause flakiness. 10 11 * http/tests/security/postMessage/resources/recv.js: 12 (recv): 13 * http/tests/security/postMessage/target-origin-expected.txt: 14 * http/tests/security/postMessage/target-origin.html: 15 1 16 2020-03-23 Per Arne Vollan <pvollan@apple.com> 2 17 -
trunk/LayoutTests/http/tests/security/postMessage/resources/recv.js
r120174 r258850 10 10 log(msg); 11 11 12 if (e.data.match(/data="runNextTest"/)) 13 runNextTest(); 14 12 15 if (e.data.match(/data="done"/) && window.testRunner) 13 16 testRunner.notifyDone(); -
trunk/LayoutTests/http/tests/security/postMessage/target-origin-expected.txt
r253497 r258850 18 18 19 19 waiting... 20 Error sending message to //. SyntaxError: The string did not match the expected pattern.21 20 Received message: data="Received message: data="Trying origin=http://localhost:8000" origin="http://127.0.0.1:8000"" origin="http://localhost:8000" 22 21 Received message: data="Received message: data="Trying origin=http://localhost:8000/" origin="http://127.0.0.1:8000"" origin="http://localhost:8000" … … 26 25 Received message: data="Received message: data="Trying origin=http://user:pass@localhost:8000/foo?bar#baz" origin="http://127.0.0.1:8000"" origin="http://localhost:8000" 27 26 Received message: data="Received message: data="Trying origin=*" origin="http://127.0.0.1:8000"" origin="http://localhost:8000" 27 Received message: data="Received message: data="runNextTest" origin="http://127.0.0.1:8000"" origin="http://localhost:8000" 28 Error sending message to //. SyntaxError: The string did not match the expected pattern. 28 29 Received message: data="Received message: data="Trying origin=/" origin="http://127.0.0.1:8000"" origin="http://127.0.0.1:8000" 29 Received message: data="Received message: data="done" origin="http://127.0.0.1:8000"" origin="http:// localhost:8000"30 Received message: data="Received message: data="done" origin="http://127.0.0.1:8000"" origin="http://127.0.0.1:8000" -
trunk/LayoutTests/http/tests/security/postMessage/target-origin.html
r120174 r258850 19 19 } 20 20 21 function runNextTest() { 22 var win127 = document.getElementById('iframe-127').contentWindow; 23 24 // Should succeed: 25 tryPostMessage(win127, "/"); 26 27 // Should throw syntax error: 28 tryPostMessage(win127, "//"); 29 30 win127.postMessage('done', '*'); 31 } 32 21 33 function test() { 22 34 var winLocalhost = document.getElementById('iframe-localhost').contentWindow; 23 var win127= document.getElementById('iframe-127').contentWindow;24 35 25 36 // Should succeed: … … 31 42 tryPostMessage(winLocalhost, "http://user:pass@localhost:8000/foo?bar#baz"); 32 43 tryPostMessage(winLocalhost, "*"); 33 tryPostMessage(win127, "/");34 44 35 45 // Should fail: … … 44 54 tryPostMessage(winLocalhost, null); 45 55 tryPostMessage(winLocalhost, undefined); 46 tryPostMessage(win127, "//"); 47 48 winLocalhost.postMessage('done', '*'); 56 57 winLocalhost.postMessage('runNextTest', '*'); 49 58 } 50 59 </script> -
trunk/LayoutTests/imported/w3c/ChangeLog
r258769 r258850 1 2020-03-23 Chris Dumez <cdumez@apple.com> 2 3 Port window.postMessage to the HTML event loop 4 https://bugs.webkit.org/show_bug.cgi?id=209359 5 6 Reviewed by Alex Christensen. 7 8 Rebaseline test now that the logging ordering is slightly different. 9 10 * web-platform-tests/html/browsers/origin/cross-origin-objects/cross-origin-objects-expected.txt: 11 1 12 2020-03-20 youenn fablet <youenn@apple.com> 2 13 -
trunk/LayoutTests/imported/w3c/web-platform-tests/html/browsers/origin/cross-origin-objects/cross-origin-objects-expected.txt
r253497 r258850 8 8 CONSOLE MESSAGE: line 302: Blocked a frame with origin "http://localhost:8800" from accessing a frame with origin "http://127.0.0.1:8800". Protocols, domains, and ports must match. 9 9 CONSOLE MESSAGE: line 302: Blocked a frame with origin "http://localhost:8800" from accessing a frame with origin "http://127.0.0.1:8800". Protocols, domains, and ports must match. 10 CONSOLE MESSAGE: Unable to post message to http://does-not.exist. Recipient has origin http://localhost:8800. 11 10 12 CONSOLE MESSAGE: Unable to post message to http://does-not.exist. Recipient has origin http://127.0.0.1:8800. 11 13 12 14 CONSOLE MESSAGE: Unable to post message to http://localhost:8800. Recipient has origin http://127.0.0.1:8800. 13 14 CONSOLE MESSAGE: Unable to post message to http://does-not.exist. Recipient has origin http://localhost:8800.15 15 16 16 CONSOLE MESSAGE: Unable to post message to http://does-not.exist. Recipient has origin http://127.0.0.1:8800. -
trunk/Source/WebCore/ChangeLog
r258847 r258850 1 2020-03-23 Chris Dumez <cdumez@apple.com> 2 3 Port window.postMessage to the HTML event loop 4 https://bugs.webkit.org/show_bug.cgi?id=209359 5 6 Reviewed by Alex Christensen. 7 8 Port window.postMessage to the HTML event loop instead of using a 0-timer. 9 10 * inspector/InspectorInstrumentation.cpp: 11 (WebCore::InspectorInstrumentation::willPostMessageImpl): 12 (WebCore::InspectorInstrumentation::didPostMessageImpl): 13 (WebCore::InspectorInstrumentation::didFailPostMessageImpl): 14 (WebCore::InspectorInstrumentation::willDispatchPostMessageImpl): 15 (WebCore::InspectorInstrumentation::didDispatchPostMessageImpl): 16 * inspector/InspectorInstrumentation.h: 17 (WebCore::InspectorInstrumentation::willPostMessage): 18 (WebCore::InspectorInstrumentation::didPostMessage): 19 (WebCore::InspectorInstrumentation::didFailPostMessage): 20 (WebCore::InspectorInstrumentation::willDispatchPostMessage): 21 (WebCore::InspectorInstrumentation::didDispatchPostMessage): 22 * inspector/agents/WebDebuggerAgent.cpp: 23 (WebCore::WebDebuggerAgent::willPostMessage): 24 (WebCore::WebDebuggerAgent::didPostMessage): 25 (WebCore::WebDebuggerAgent::didFailPostMessage): 26 (WebCore::WebDebuggerAgent::willDispatchPostMessage): 27 (WebCore::WebDebuggerAgent::didDispatchPostMessage): 28 (WebCore::WebDebuggerAgent::didClearAsyncStackTraceData): 29 * inspector/agents/WebDebuggerAgent.h: 30 * page/DOMWindow.cpp: 31 (WebCore::DOMWindow::postMessage): 32 (WebCore::PostMessageTimer::PostMessageTimer): Deleted. 33 (WebCore::PostMessageTimer::event): Deleted. 34 (WebCore::PostMessageTimer::targetOrigin const): Deleted. 35 (WebCore::PostMessageTimer::stackTrace const): Deleted. 36 (WebCore::DOMWindow::postMessageTimerFired): Deleted. 37 * page/DOMWindow.h: 38 1 39 2020-03-23 Zalan Bujtas <zalan@apple.com> 2 40 -
trunk/Source/WebCore/inspector/InspectorInstrumentation.cpp
r255396 r258850 362 362 } 363 363 364 void InspectorInstrumentation::didPostMessageImpl(InstrumentingAgents& instrumentingAgents, const TimerBase& timer, JSC::JSGlobalObject& state) 365 { 366 if (auto* webDebuggerAgent = instrumentingAgents.webDebuggerAgent()) 367 webDebuggerAgent->didPostMessage(timer, state); 368 } 369 370 void InspectorInstrumentation::didFailPostMessageImpl(InstrumentingAgents& instrumentingAgents, const TimerBase& timer) 371 { 372 if (auto* webDebuggerAgent = instrumentingAgents.webDebuggerAgent()) 373 webDebuggerAgent->didFailPostMessage(timer); 374 } 375 376 void InspectorInstrumentation::willDispatchPostMessageImpl(InstrumentingAgents& instrumentingAgents, const TimerBase& timer) 377 { 378 if (auto* webDebuggerAgent = instrumentingAgents.webDebuggerAgent()) 379 webDebuggerAgent->willDispatchPostMessage(timer); 380 } 381 382 void InspectorInstrumentation::didDispatchPostMessageImpl(InstrumentingAgents& instrumentingAgents, const TimerBase& timer) 383 { 384 if (auto* webDebuggerAgent = instrumentingAgents.webDebuggerAgent()) 385 webDebuggerAgent->didDispatchPostMessage(timer); 364 int InspectorInstrumentation::willPostMessageImpl(InstrumentingAgents& instrumentingAgents) 365 { 366 if (auto* webDebuggerAgent = instrumentingAgents.webDebuggerAgent()) 367 return webDebuggerAgent->willPostMessage(); 368 return 0; 369 } 370 371 void InspectorInstrumentation::didPostMessageImpl(InstrumentingAgents& instrumentingAgents, int postMessageIdentifier, JSC::JSGlobalObject& state) 372 { 373 if (auto* webDebuggerAgent = instrumentingAgents.webDebuggerAgent()) 374 webDebuggerAgent->didPostMessage(postMessageIdentifier, state); 375 } 376 377 void InspectorInstrumentation::didFailPostMessageImpl(InstrumentingAgents& instrumentingAgents, int postMessageIdentifier) 378 { 379 if (auto* webDebuggerAgent = instrumentingAgents.webDebuggerAgent()) 380 webDebuggerAgent->didFailPostMessage(postMessageIdentifier); 381 } 382 383 void InspectorInstrumentation::willDispatchPostMessageImpl(InstrumentingAgents& instrumentingAgents, int postMessageIdentifier) 384 { 385 if (auto* webDebuggerAgent = instrumentingAgents.webDebuggerAgent()) 386 webDebuggerAgent->willDispatchPostMessage(postMessageIdentifier); 387 } 388 389 void InspectorInstrumentation::didDispatchPostMessageImpl(InstrumentingAgents& instrumentingAgents, int postMessageIdentifier) 390 { 391 if (auto* webDebuggerAgent = instrumentingAgents.webDebuggerAgent()) 392 webDebuggerAgent->didDispatchPostMessage(postMessageIdentifier); 386 393 } 387 394 -
trunk/Source/WebCore/inspector/InspectorInstrumentation.h
r255396 r258850 156 156 static void didRemoveTimer(ScriptExecutionContext&, int timerId); 157 157 158 static void didPostMessage(Frame&, TimerBase&, JSC::JSGlobalObject&); 159 static void didFailPostMessage(Frame&, TimerBase&); 160 static void willDispatchPostMessage(Frame&, TimerBase&); 161 static void didDispatchPostMessage(Frame&, TimerBase&); 158 static int willPostMessage(Frame&); 159 static void didPostMessage(Frame&, int postTimerIdentifier, JSC::JSGlobalObject&); 160 static void didFailPostMessage(Frame&, int postTimerIdentifier); 161 static void willDispatchPostMessage(Frame&, int postTimerIdentifier); 162 static void didDispatchPostMessage(Frame&, int postTimerIdentifier); 162 163 163 164 static void willCallFunction(ScriptExecutionContext*, const String& scriptName, int scriptLine, int scriptColumn); … … 374 375 static void didRemoveTimerImpl(InstrumentingAgents&, int timerId, ScriptExecutionContext&); 375 376 376 static void didPostMessageImpl(InstrumentingAgents&, const TimerBase&, JSC::JSGlobalObject&); 377 static void didFailPostMessageImpl(InstrumentingAgents&, const TimerBase&); 378 static void willDispatchPostMessageImpl(InstrumentingAgents&, const TimerBase&); 379 static void didDispatchPostMessageImpl(InstrumentingAgents&, const TimerBase&); 377 static int willPostMessageImpl(InstrumentingAgents&); 378 static void didPostMessageImpl(InstrumentingAgents&, int postMessageIdentifier, JSC::JSGlobalObject&); 379 static void didFailPostMessageImpl(InstrumentingAgents&, int postMessageIdentifier); 380 static void willDispatchPostMessageImpl(InstrumentingAgents&, int postMessageIdentifier); 381 static void didDispatchPostMessageImpl(InstrumentingAgents&, int postMessageIdentifier); 380 382 381 383 static void willCallFunctionImpl(InstrumentingAgents&, const String& scriptName, int scriptLine, int scriptColumn, ScriptExecutionContext*); … … 808 810 } 809 811 810 inline void InspectorInstrumentation::didPostMessage(Frame& frame, TimerBase& timer, JSC::JSGlobalObject& state) 811 { 812 FAST_RETURN_IF_NO_FRONTENDS(void()); 813 if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForFrame(frame)) 814 didPostMessageImpl(*instrumentingAgents, timer, state); 815 } 816 817 inline void InspectorInstrumentation::didFailPostMessage(Frame& frame, TimerBase& timer) 818 { 819 FAST_RETURN_IF_NO_FRONTENDS(void()); 820 if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForFrame(frame)) 821 didFailPostMessageImpl(*instrumentingAgents, timer); 822 } 823 824 inline void InspectorInstrumentation::willDispatchPostMessage(Frame& frame, TimerBase& timer) 825 { 826 FAST_RETURN_IF_NO_FRONTENDS(void()); 827 if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForFrame(frame)) 828 willDispatchPostMessageImpl(*instrumentingAgents, timer); 829 } 830 831 inline void InspectorInstrumentation::didDispatchPostMessage(Frame& frame, TimerBase& timer) 832 { 833 FAST_RETURN_IF_NO_FRONTENDS(void()); 834 if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForFrame(frame)) 835 didDispatchPostMessageImpl(*instrumentingAgents, timer); 812 inline int InspectorInstrumentation::willPostMessage(Frame& frame) 813 { 814 FAST_RETURN_IF_NO_FRONTENDS(0); 815 if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForFrame(frame)) 816 return willPostMessageImpl(*instrumentingAgents); 817 return 0; 818 } 819 820 inline void InspectorInstrumentation::didPostMessage(Frame& frame, int postMessageIdentifier, JSC::JSGlobalObject& state) 821 { 822 FAST_RETURN_IF_NO_FRONTENDS(void()); 823 if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForFrame(frame)) 824 didPostMessageImpl(*instrumentingAgents, postMessageIdentifier, state); 825 } 826 827 inline void InspectorInstrumentation::didFailPostMessage(Frame& frame, int postMessageIdentifier) 828 { 829 FAST_RETURN_IF_NO_FRONTENDS(void()); 830 if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForFrame(frame)) 831 didFailPostMessageImpl(*instrumentingAgents, postMessageIdentifier); 832 } 833 834 inline void InspectorInstrumentation::willDispatchPostMessage(Frame& frame, int postMessageIdentifier) 835 { 836 FAST_RETURN_IF_NO_FRONTENDS(void()); 837 if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForFrame(frame)) 838 willDispatchPostMessageImpl(*instrumentingAgents, postMessageIdentifier); 839 } 840 841 inline void InspectorInstrumentation::didDispatchPostMessage(Frame& frame, int postMessageIdentifier) 842 { 843 FAST_RETURN_IF_NO_FRONTENDS(void()); 844 if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForFrame(frame)) 845 didDispatchPostMessageImpl(*instrumentingAgents, postMessageIdentifier); 836 846 } 837 847 -
trunk/Source/WebCore/inspector/agents/WebDebuggerAgent.cpp
r251425 r258850 113 113 } 114 114 115 void WebDebuggerAgent::didPostMessage(const TimerBase& timer, JSC::JSGlobalObject& state) 115 int WebDebuggerAgent::willPostMessage() 116 { 117 if (!breakpointsActive()) 118 return 0; 119 120 auto postMessageIdentifier = m_nextPostMessageIdentifier++; 121 m_postMessageTasks.add(postMessageIdentifier); 122 return postMessageIdentifier; 123 } 124 125 void WebDebuggerAgent::didPostMessage(int postMessageIdentifier, JSC::JSGlobalObject& state) 116 126 { 117 127 if (!breakpointsActive()) 118 128 return; 119 129 120 if ( m_postMessageTimers.contains(&timer))130 if (!postMessageIdentifier || !m_postMessageTasks.contains(postMessageIdentifier)) 121 131 return; 122 123 int postMessageIdentifier = m_nextPostMessageIdentifier++;124 m_postMessageTimers.set(&timer, postMessageIdentifier);125 132 126 133 didScheduleAsyncCall(&state, InspectorDebuggerAgent::AsyncCallType::PostMessage, postMessageIdentifier, true); 127 134 } 128 135 129 void WebDebuggerAgent::didFailPostMessage( const TimerBase& timer)136 void WebDebuggerAgent::didFailPostMessage(int postMessageIdentifier) 130 137 { 131 auto it = m_postMessageTimers.find(&timer); 132 if (it == m_postMessageTimers.end()) 138 if (!postMessageIdentifier) 133 139 return; 134 140 135 didCancelAsyncCall(InspectorDebuggerAgent::AsyncCallType::PostMessage, it->value); 141 auto it = m_postMessageTasks.find(postMessageIdentifier); 142 if (it == m_postMessageTasks.end()) 143 return; 136 144 137 m_postMessageTimers.remove(it); 145 didCancelAsyncCall(InspectorDebuggerAgent::AsyncCallType::PostMessage, postMessageIdentifier); 146 147 m_postMessageTasks.remove(it); 138 148 } 139 149 140 void WebDebuggerAgent::willDispatchPostMessage( const TimerBase& timer)150 void WebDebuggerAgent::willDispatchPostMessage(int postMessageIdentifier) 141 151 { 142 auto it = m_postMessageTimers.find(&timer); 143 if (it == m_postMessageTimers.end()) 152 if (!postMessageIdentifier || !m_postMessageTasks.contains(postMessageIdentifier)) 144 153 return; 145 154 146 willDispatchAsyncCall(InspectorDebuggerAgent::AsyncCallType::PostMessage, it->value);155 willDispatchAsyncCall(InspectorDebuggerAgent::AsyncCallType::PostMessage, postMessageIdentifier); 147 156 } 148 157 149 void WebDebuggerAgent::didDispatchPostMessage( const TimerBase& timer)158 void WebDebuggerAgent::didDispatchPostMessage(int postMessageIdentifier) 150 159 { 151 auto it = m_postMessageTimers.find(&timer); 152 if (it == m_postMessageTimers.end()) 160 if (!postMessageIdentifier) 161 return; 162 163 auto it = m_postMessageTasks.find(postMessageIdentifier); 164 if (it == m_postMessageTasks.end()) 153 165 return; 154 166 155 167 didDispatchAsyncCall(); 156 168 157 m_postMessageT imers.remove(it);169 m_postMessageTasks.remove(it); 158 170 } 159 171 … … 161 173 { 162 174 m_registeredEventListeners.clear(); 163 m_postMessageT imers.clear();175 m_postMessageTasks.clear(); 164 176 m_nextEventListenerIdentifier = 1; 165 177 m_nextPostMessageIdentifier = 1; -
trunk/Source/WebCore/inspector/agents/WebDebuggerAgent.h
r251425 r258850 49 49 void willRemoveEventListener(EventTarget&, const AtomString& eventType, EventListener&, bool capture); 50 50 void willHandleEvent(const RegisteredEventListener&); 51 void didPostMessage(const TimerBase&, JSC::JSGlobalObject&); 52 void didFailPostMessage(const TimerBase&); 53 void willDispatchPostMessage(const TimerBase&); 54 void didDispatchPostMessage(const TimerBase&); 51 int willPostMessage(); 52 void didPostMessage(int postMessageIdentifier, JSC::JSGlobalObject&); 53 void didFailPostMessage(int postMessageIdentifier); 54 void willDispatchPostMessage(int postMessageIdentifier); 55 void didDispatchPostMessage(int postMessageIdentifier); 55 56 56 57 protected: … … 65 66 private: 66 67 HashMap<const RegisteredEventListener*, int> m_registeredEventListeners; 67 Hash Map<const TimerBase*, int> m_postMessageTimers;68 HashSet<int> m_postMessageTasks; 68 69 int m_nextEventListenerIdentifier { 1 }; 69 70 int m_nextPostMessageIdentifier { 1 }; -
trunk/Source/WebCore/page/DOMWindow.cpp
r257767 r258850 165 165 WTF_MAKE_ISO_ALLOCATED_IMPL(DOMWindow); 166 166 167 class PostMessageTimer : public TimerBase {168 public:169 PostMessageTimer(DOMWindow& window, MessageWithMessagePorts&& message, const String& sourceOrigin, RefPtr<WindowProxy>&& source, RefPtr<SecurityOrigin>&& targetOrigin, RefPtr<ScriptCallStack>&& stackTrace)170 : m_window(window)171 , m_message(WTFMove(message))172 , m_origin(sourceOrigin)173 , m_source(source)174 , m_targetOrigin(WTFMove(targetOrigin))175 , m_stackTrace(stackTrace)176 , m_userGestureToForward(UserGestureIndicator::currentUserGesture())177 {178 }179 180 Ref<MessageEvent> event(ScriptExecutionContext& context)181 {182 return MessageEvent::create(MessagePort::entanglePorts(context, WTFMove(m_message.transferredPorts)), m_message.message.releaseNonNull(), m_origin, { }, m_source ? makeOptional(MessageEventSource(WTFMove(m_source))) : WTF::nullopt);183 }184 185 SecurityOrigin* targetOrigin() const { return m_targetOrigin.get(); }186 ScriptCallStack* stackTrace() const { return m_stackTrace.get(); }187 188 private:189 void fired() override190 {191 // This object gets deleted when std::unique_ptr falls out of scope..192 std::unique_ptr<PostMessageTimer> timer(this);193 194 UserGestureIndicator userGestureIndicator(m_userGestureToForward);195 m_window->postMessageTimerFired(*timer);196 }197 198 Ref<DOMWindow> m_window;199 MessageWithMessagePorts m_message;200 String m_origin;201 RefPtr<WindowProxy> m_source;202 RefPtr<SecurityOrigin> m_targetOrigin;203 RefPtr<ScriptCallStack> m_stackTrace;204 RefPtr<UserGestureToken> m_userGestureToForward;205 };206 207 167 typedef HashCountedSet<DOMWindow*> DOMWindowSet; 208 168 … … 931 891 stackTrace = createScriptCallStack(JSExecState::currentState()); 932 892 893 auto postMessageIdentifier = InspectorInstrumentation::willPostMessage(*frame()); 894 933 895 MessageWithMessagePorts message { messageData.releaseReturnValue(), disentangledPorts.releaseReturnValue() }; 934 896 935 897 // Schedule the message. 936 898 RefPtr<WindowProxy> incumbentWindowProxy = incumbentWindow.frame() ? &incumbentWindow.frame()->windowProxy() : nullptr; 937 auto* timer = new PostMessageTimer(*this, WTFMove(message), sourceOrigin, WTFMove(incumbentWindowProxy), WTFMove(target), WTFMove(stackTrace)); 938 timer->startOneShot(0_s); 939 940 InspectorInstrumentation::didPostMessage(*frame(), *timer, lexicalGlobalObject); 899 auto userGestureToForward = UserGestureIndicator::currentUserGesture(); 900 901 document()->eventLoop().queueTask(TaskSource::PostedMessageQueue, [this, protectedThis = makeRef(*this), message = WTFMove(message), incumbentWindowProxy = WTFMove(incumbentWindowProxy), sourceOrigin = WTFMove(sourceOrigin), userGestureToForward = WTFMove(userGestureToForward), postMessageIdentifier, stackTrace = WTFMove(stackTrace), targetOrigin = WTFMove(target)]() mutable { 902 if (!isCurrentlyDisplayedInFrame()) 903 return; 904 905 Ref<Frame> frame = *this->frame(); 906 if (targetOrigin) { 907 // Check target origin now since the target document may have changed since the timer was scheduled. 908 if (!targetOrigin->isSameSchemeHostPort(document()->securityOrigin())) { 909 if (auto* pageConsole = console()) { 910 String message = makeString("Unable to post message to ", targetOrigin->toString(), ". Recipient has origin ", document()->securityOrigin().toString(), ".\n"); 911 if (stackTrace) 912 pageConsole->addMessage(MessageSource::Security, MessageLevel::Error, message, *stackTrace); 913 else 914 pageConsole->addMessage(MessageSource::Security, MessageLevel::Error, message); 915 } 916 917 InspectorInstrumentation::didFailPostMessage(frame, postMessageIdentifier); 918 return; 919 } 920 } 921 922 UserGestureIndicator userGestureIndicator(userGestureToForward); 923 InspectorInstrumentation::willDispatchPostMessage(frame, postMessageIdentifier); 924 925 auto event = MessageEvent::create(MessagePort::entanglePorts(*document(), WTFMove(message.transferredPorts)), message.message.releaseNonNull(), sourceOrigin, { }, incumbentWindowProxy ? makeOptional(MessageEventSource(WTFMove(incumbentWindowProxy))) : WTF::nullopt); 926 dispatchEvent(event); 927 928 InspectorInstrumentation::didDispatchPostMessage(frame, postMessageIdentifier); 929 }); 930 931 InspectorInstrumentation::didPostMessage(*frame(), postMessageIdentifier, lexicalGlobalObject); 941 932 942 933 return { }; 943 }944 945 void DOMWindow::postMessageTimerFired(PostMessageTimer& timer)946 {947 if (!document() || !isCurrentlyDisplayedInFrame())948 return;949 950 Ref<Frame> frame = *this->frame();951 if (auto* intendedTargetOrigin = timer.targetOrigin()) {952 // Check target origin now since the target document may have changed since the timer was scheduled.953 if (!intendedTargetOrigin->isSameSchemeHostPort(document()->securityOrigin())) {954 if (auto* pageConsole = console()) {955 String message = makeString("Unable to post message to ", intendedTargetOrigin->toString(), ". Recipient has origin ", document()->securityOrigin().toString(), ".\n");956 if (timer.stackTrace())957 pageConsole->addMessage(MessageSource::Security, MessageLevel::Error, message, *timer.stackTrace());958 else959 pageConsole->addMessage(MessageSource::Security, MessageLevel::Error, message);960 }961 962 InspectorInstrumentation::didFailPostMessage(frame, timer);963 return;964 }965 }966 967 InspectorInstrumentation::willDispatchPostMessage(frame, timer);968 969 dispatchEvent(timer.event(*document()));970 971 InspectorInstrumentation::didDispatchPostMessage(frame, timer);972 934 } 973 935 -
trunk/Source/WebCore/page/DOMWindow.h
r255668 r258850 76 76 class PageConsoleClient; 77 77 class Performance; 78 class PostMessageTimer;79 78 class RequestAnimationFrameCallback; 80 79 class RequestIdleCallback; … … 276 275 return postMessage(globalObject, incumbentWindow, message, WindowPostMessageOptions { WTFMove(targetOrigin), WTFMove(transfer) }); 277 276 } 278 279 void postMessageTimerFired(PostMessageTimer&);280 277 281 278 void languagesChanged();
Note: See TracChangeset
for help on using the changeset viewer.