| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include <stddef.h> | 5 #include <stddef.h> |
| 6 | 6 |
| 7 #include <memory> | 7 #include <memory> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/cancelable_callback.h" | 10 #include "base/cancelable_callback.h" |
| (...skipping 982 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 993 " null,\n" | 993 " null,\n" |
| 994 " 'panel.html',\n" | 994 " 'panel.html',\n" |
| 995 " function(panel) {\n" | 995 " function(panel) {\n" |
| 996 " chrome.devtools.inspectedWindow.eval('console.log(\"PASS\")');\n" | 996 " chrome.devtools.inspectedWindow.eval('console.log(\"PASS\")');\n" |
| 997 " }\n" | 997 " }\n" |
| 998 ");\n"); | 998 ");\n"); |
| 999 | 999 |
| 1000 dir->WriteFile(FILE_PATH_LITERAL("panel.html"), | 1000 dir->WriteFile(FILE_PATH_LITERAL("panel.html"), |
| 1001 "<html><body>A panel." | 1001 "<html><body>A panel." |
| 1002 "<script src='blob_xhr.js'></script>" | 1002 "<script src='blob_xhr.js'></script>" |
| 1003 "<script src='blob_iframe.js'></script>" |
| 1003 "</body></html>"); | 1004 "</body></html>"); |
| 1004 // Creating blobs from chrome-extension:// origins is only permitted if the | 1005 // Creating blobs from chrome-extension:// origins is only permitted if the |
| 1005 // process has been granted permission to commit 'chrome-extension' schemes. | 1006 // process has been granted permission to commit 'chrome-extension' schemes. |
| 1006 dir->WriteFile( | 1007 dir->WriteFile( |
| 1007 FILE_PATH_LITERAL("blob_xhr.js"), | 1008 FILE_PATH_LITERAL("blob_xhr.js"), |
| 1008 "var blob_url = URL.createObjectURL(new Blob(['blob contents']));\n" | 1009 "var blob_url = URL.createObjectURL(new Blob(['xhr blob contents']));\n" |
| 1009 "var xhr = new XMLHttpRequest();\n" | 1010 "var xhr = new XMLHttpRequest();\n" |
| 1010 "xhr.open('GET', blob_url, true);\n" | 1011 "xhr.open('GET', blob_url, true);\n" |
| 1011 "xhr.onload = function (e) {\n" | 1012 "xhr.onload = function (e) {\n" |
| 1012 " domAutomationController.setAutomationId(0);\n" | 1013 " domAutomationController.setAutomationId(0);\n" |
| 1013 " domAutomationController.send(xhr.response);\n" | 1014 " domAutomationController.send(xhr.response);\n" |
| 1014 "};\n" | 1015 "};\n" |
| 1015 "xhr.send(null);\n"); | 1016 "xhr.send(null);\n"); |
| 1017 dir->WriteFile( |
| 1018 FILE_PATH_LITERAL("blob_iframe.js"), |
| 1019 "var payload = `" |
| 1020 "<html><body>iframe blob contents" |
| 1021 "<script>" |
| 1022 " domAutomationController.setAutomationId(0);" |
| 1023 " domAutomationController.send(document.body.innerText);\n" |
| 1024 "</script></body></html>" |
| 1025 "`;" |
| 1026 "document.body.appendChild(document.createElement('iframe')).src =" |
| 1027 " URL.createObjectURL(new Blob([payload], {type: 'text/html'}));"); |
| 1016 // Install the extension. | 1028 // Install the extension. |
| 1017 const Extension* extension = LoadExtensionFromPath(dir->UnpackedPath()); | 1029 const Extension* extension = LoadExtensionFromPath(dir->UnpackedPath()); |
| 1018 ASSERT_TRUE(extension); | 1030 ASSERT_TRUE(extension); |
| 1019 | 1031 |
| 1020 // Open a devtools window. | 1032 // Open a devtools window. |
| 1021 OpenDevToolsWindow(kDebuggerTestPage, false); | 1033 OpenDevToolsWindow(kDebuggerTestPage, false); |
| 1022 | 1034 |
| 1023 // Wait for the panel extension to finish loading -- it'll output 'PASS' | 1035 // Wait for the panel extension to finish loading -- it'll output 'PASS' |
| 1024 // when it's installed. waitForTestResultsInConsole waits until that 'PASS'. | 1036 // when it's installed. waitForTestResultsInConsole waits until that 'PASS'. |
| 1025 RunTestFunction(window_, "waitForTestResultsInConsole"); | 1037 RunTestFunction(window_, "waitForTestResultsInConsole"); |
| 1026 | 1038 |
| 1027 // Now that we know the panel is loaded, switch to it. We'll wait until we | 1039 // Now that we know the panel is loaded, switch to it. We'll wait until we |
| 1028 // see a 'DONE' message sent from popup_iframe.html, indicating that it | 1040 // see a 'DONE' message sent from popup_iframe.html, indicating that it |
| 1029 // loaded successfully. | 1041 // loaded successfully. |
| 1030 content::DOMMessageQueue message_queue; | 1042 content::DOMMessageQueue message_queue; |
| 1031 SwitchToExtensionPanel(window_, extension, "the_panel_name"); | 1043 SwitchToExtensionPanel(window_, extension, "the_panel_name"); |
| 1032 std::string message; | 1044 std::string message; |
| 1033 while (true) { | 1045 while (true) { |
| 1034 ASSERT_TRUE(message_queue.WaitForMessage(&message)); | 1046 ASSERT_TRUE(message_queue.WaitForMessage(&message)); |
| 1035 if (message == "\"blob contents\"") | 1047 if (message == "\"xhr blob contents\"") |
| 1048 break; |
| 1049 } |
| 1050 while (true) { |
| 1051 ASSERT_TRUE(message_queue.WaitForMessage(&message)); |
| 1052 if (message == "\"iframe blob contents\"") |
| 1036 break; | 1053 break; |
| 1037 } | 1054 } |
| 1038 } | 1055 } |
| 1039 | 1056 |
| 1040 // Disabled on Windows due to flakiness. http://crbug.com/183649 | 1057 // Disabled on Windows due to flakiness. http://crbug.com/183649 |
| 1041 #if defined(OS_WIN) | 1058 #if defined(OS_WIN) |
| 1042 #define MAYBE_TestDevToolsExtensionMessaging DISABLED_TestDevToolsExtensionMessa
ging | 1059 #define MAYBE_TestDevToolsExtensionMessaging DISABLED_TestDevToolsExtensionMessa
ging |
| 1043 #else | 1060 #else |
| 1044 #define MAYBE_TestDevToolsExtensionMessaging TestDevToolsExtensionMessaging | 1061 #define MAYBE_TestDevToolsExtensionMessaging TestDevToolsExtensionMessaging |
| 1045 #endif | 1062 #endif |
| (...skipping 472 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1518 | 1535 |
| 1519 DevToolsWindowTesting::CloseDevToolsWindowSync(window); | 1536 DevToolsWindowTesting::CloseDevToolsWindowSync(window); |
| 1520 content::WebUIControllerFactory::UnregisterFactoryForTesting(&test_factory); | 1537 content::WebUIControllerFactory::UnregisterFactoryForTesting(&test_factory); |
| 1521 } | 1538 } |
| 1522 | 1539 |
| 1523 // Tests scripts panel showing. | 1540 // Tests scripts panel showing. |
| 1524 IN_PROC_BROWSER_TEST_F(DevToolsSanityTest, TestDevToolsSharedWorker) { | 1541 IN_PROC_BROWSER_TEST_F(DevToolsSanityTest, TestDevToolsSharedWorker) { |
| 1525 RunTest("testDevToolsSharedWorker", url::kAboutBlankURL); | 1542 RunTest("testDevToolsSharedWorker", url::kAboutBlankURL); |
| 1526 } | 1543 } |
| 1527 | 1544 |
| OLD | NEW |