| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2010 Google Inc. All rights reserved. | 2 * Copyright (C) 2010 Google Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
| 6 * met: | 6 * met: |
| 7 * | 7 * |
| 8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
| 9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
| 10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
| (...skipping 20 matching lines...) Expand all Loading... |
| 31 #include "public/web/WebFrame.h" | 31 #include "public/web/WebFrame.h" |
| 32 | 32 |
| 33 #include <stdarg.h> | 33 #include <stdarg.h> |
| 34 #include <v8.h> | 34 #include <v8.h> |
| 35 #include <map> | 35 #include <map> |
| 36 #include <memory> | 36 #include <memory> |
| 37 #include "SkBitmap.h" | 37 #include "SkBitmap.h" |
| 38 #include "SkCanvas.h" | 38 #include "SkCanvas.h" |
| 39 #include "bindings/core/v8/SerializedScriptValueFactory.h" | 39 #include "bindings/core/v8/SerializedScriptValueFactory.h" |
| 40 #include "bindings/core/v8/V8Node.h" | 40 #include "bindings/core/v8/V8Node.h" |
| 41 #include "bindings/core/v8/serialization/V8ScriptValueSerializer.h" |
| 41 #include "core/clipboard/DataTransfer.h" | 42 #include "core/clipboard/DataTransfer.h" |
| 42 #include "core/css/StyleSheetContents.h" | 43 #include "core/css/StyleSheetContents.h" |
| 43 #include "core/css/resolver/StyleResolver.h" | 44 #include "core/css/resolver/StyleResolver.h" |
| 44 #include "core/css/resolver/ViewportStyleResolver.h" | 45 #include "core/css/resolver/ViewportStyleResolver.h" |
| 45 #include "core/dom/Document.h" | 46 #include "core/dom/Document.h" |
| 46 #include "core/dom/DocumentUserGestureToken.h" | 47 #include "core/dom/DocumentUserGestureToken.h" |
| 47 #include "core/dom/Fullscreen.h" | 48 #include "core/dom/Fullscreen.h" |
| 48 #include "core/dom/NodeComputedStyle.h" | 49 #include "core/dom/NodeComputedStyle.h" |
| 49 #include "core/dom/Range.h" | 50 #include "core/dom/Range.h" |
| 50 #include "core/editing/Editor.h" | 51 #include "core/editing/Editor.h" |
| (...skipping 932 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 983 incorrectOrigin, message); | 984 incorrectOrigin, message); |
| 984 | 985 |
| 985 // Verify that only the first addition is in the body of the page. | 986 // Verify that only the first addition is in the body of the page. |
| 986 std::string content = | 987 std::string content = |
| 987 WebFrameContentDumper::dumpWebViewAsText(webViewHelper.webView(), 1024) | 988 WebFrameContentDumper::dumpWebViewAsText(webViewHelper.webView(), 1024) |
| 988 .utf8(); | 989 .utf8(); |
| 989 EXPECT_NE(std::string::npos, content.find("Message 1.")); | 990 EXPECT_NE(std::string::npos, content.find("Message 1.")); |
| 990 EXPECT_EQ(std::string::npos, content.find("Message 2.")); | 991 EXPECT_EQ(std::string::npos, content.find("Message 2.")); |
| 991 } | 992 } |
| 992 | 993 |
| 994 namespace { |
| 995 |
| 996 RefPtr<SerializedScriptValue> serializeString(const StringView& message, |
| 997 ScriptState* scriptState) { |
| 998 // This is inefficient, but avoids duplicating serialization logic for the |
| 999 // sake of this test. |
| 1000 NonThrowableExceptionState exceptionState; |
| 1001 ScriptState::Scope scope(scriptState); |
| 1002 V8ScriptValueSerializer serializer(scriptState); |
| 1003 return serializer.serialize(v8String(scriptState->isolate(), message), |
| 1004 nullptr, exceptionState); |
| 1005 } |
| 1006 |
| 1007 } // namespace |
| 1008 |
| 993 TEST_P(ParameterizedWebFrameTest, PostMessageThenDetach) { | 1009 TEST_P(ParameterizedWebFrameTest, PostMessageThenDetach) { |
| 994 FrameTestHelpers::WebViewHelper webViewHelper; | 1010 FrameTestHelpers::WebViewHelper webViewHelper; |
| 995 webViewHelper.initializeAndLoad("about:blank"); | 1011 webViewHelper.initializeAndLoad("about:blank"); |
| 996 | 1012 |
| 997 LocalFrame* frame = | 1013 LocalFrame* frame = |
| 998 toLocalFrame(webViewHelper.webView()->page()->mainFrame()); | 1014 toLocalFrame(webViewHelper.webView()->page()->mainFrame()); |
| 999 NonThrowableExceptionState exceptionState; | 1015 NonThrowableExceptionState exceptionState; |
| 1016 RefPtr<SerializedScriptValue> message = |
| 1017 serializeString("message", ScriptState::forMainWorld(frame)); |
| 1000 MessagePortArray messagePorts; | 1018 MessagePortArray messagePorts; |
| 1001 frame->domWindow()->postMessage(SerializedScriptValue::serialize("message"), | 1019 frame->domWindow()->postMessage(message, messagePorts, "*", |
| 1002 messagePorts, "*", frame->domWindow(), | 1020 frame->domWindow(), exceptionState); |
| 1003 exceptionState); | |
| 1004 webViewHelper.reset(); | 1021 webViewHelper.reset(); |
| 1005 EXPECT_FALSE(exceptionState.hadException()); | 1022 EXPECT_FALSE(exceptionState.hadException()); |
| 1006 | 1023 |
| 1007 // Success is not crashing. | 1024 // Success is not crashing. |
| 1008 runPendingTasks(); | 1025 runPendingTasks(); |
| 1009 } | 1026 } |
| 1010 | 1027 |
| 1011 namespace { | 1028 namespace { |
| 1012 | 1029 |
| 1013 class FixedLayoutTestWebViewClient | 1030 class FixedLayoutTestWebViewClient |
| (...skipping 10356 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 11370 | 11387 |
| 11371 EXPECT_TRUE(mainFrameClient.childClient().didCallFrameDetached()); | 11388 EXPECT_TRUE(mainFrameClient.childClient().didCallFrameDetached()); |
| 11372 EXPECT_TRUE(mainFrameClient.childClient().didCallDidStopLoading()); | 11389 EXPECT_TRUE(mainFrameClient.childClient().didCallDidStopLoading()); |
| 11373 EXPECT_TRUE(mainFrameClient.childClient().didCallDidFinishDocumentLoad()); | 11390 EXPECT_TRUE(mainFrameClient.childClient().didCallDidFinishDocumentLoad()); |
| 11374 EXPECT_TRUE(mainFrameClient.childClient().didCallDidHandleOnloadEvents()); | 11391 EXPECT_TRUE(mainFrameClient.childClient().didCallDidHandleOnloadEvents()); |
| 11375 | 11392 |
| 11376 webViewHelper.reset(); | 11393 webViewHelper.reset(); |
| 11377 } | 11394 } |
| 11378 | 11395 |
| 11379 } // namespace blink | 11396 } // namespace blink |
| OLD | NEW |