Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(75)

Side by Side Diff: headless/public/util/flat_dom_tree_extractor_browsertest.cc

Issue 2683603002: FlatDomTreeExtractor to enable & disable DOM domain (Closed)
Patch Set: Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « headless/public/util/flat_dom_tree_extractor.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2017 The Chromium Authors. All rights reserved. 1 // Copyright 2017 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 "headless/public/util/flat_dom_tree_extractor.h" 5 #include "headless/public/util/flat_dom_tree_extractor.h"
6 6
7 #include <memory> 7 #include <memory>
8 #include "base/json/json_reader.h" 8 #include "base/json/json_reader.h"
9 #include "base/json/json_writer.h" 9 #include "base/json/json_writer.h"
10 #include "base/strings/string_util.h" 10 #include "base/strings/string_util.h"
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
48 devtools_client_->GetPage()->Navigate( 48 devtools_client_->GetPage()->Navigate(
49 embedded_test_server()->GetURL("/dom_tree_test.html").spec()); 49 embedded_test_server()->GetURL("/dom_tree_test.html").spec());
50 } 50 }
51 51
52 void OnLoadEventFired(const page::LoadEventFiredParams& params) override { 52 void OnLoadEventFired(const page::LoadEventFiredParams& params) override {
53 devtools_client_->GetPage()->Disable(); 53 devtools_client_->GetPage()->Disable();
54 devtools_client_->GetPage()->RemoveObserver(this); 54 devtools_client_->GetPage()->RemoveObserver(this);
55 55
56 extractor_.reset(new FlatDomTreeExtractor(devtools_client_.get())); 56 extractor_.reset(new FlatDomTreeExtractor(devtools_client_.get()));
57 57
58 devtools_client_->GetDOM()->Enable();
59 std::vector<std::string> css_whitelist = { 58 std::vector<std::string> css_whitelist = {
60 "color", "display", "font-style", "font-family", 59 "color", "display", "font-style", "font-family",
61 "margin-left", "margin-right", "margin-top", "margin-bottom"}; 60 "margin-left", "margin-right", "margin-top", "margin-bottom"};
62 extractor_->ExtractDomTree( 61 extractor_->ExtractDomTree(
63 css_whitelist, 62 css_whitelist,
64 base::Bind(&FlatDomTreeExtractorBrowserTest::OnDomTreeExtracted, 63 base::Bind(&FlatDomTreeExtractorBrowserTest::OnDomTreeExtracted,
65 base::Unretained(this))); 64 base::Unretained(this)));
66 } 65 }
67 66
68 void OnDomTreeExtracted(FlatDomTreeExtractor::DomTree dom_tree) { 67 void OnDomTreeExtracted(FlatDomTreeExtractor::DomTree dom_tree) {
(...skipping 835 matching lines...) Expand 10 before | Expand all | Expand 10 after
904 std::string result_json; 903 std::string result_json;
905 base::JSONWriter::WriteWithOptions(*computed_styles[i], 904 base::JSONWriter::WriteWithOptions(*computed_styles[i],
906 base::JSONWriter::OPTIONS_PRETTY_PRINT, 905 base::JSONWriter::OPTIONS_PRETTY_PRINT,
907 &result_json); 906 &result_json);
908 907
909 ASSERT_LT(i, expected_styles.size()); 908 ASSERT_LT(i, expected_styles.size());
910 EXPECT_EQ(NormaliseJSON(expected_styles[i]), result_json) << " Style # " 909 EXPECT_EQ(NormaliseJSON(expected_styles[i]), result_json) << " Style # "
911 << i; 910 << i;
912 } 911 }
913 912
914 devtools_client_->GetDOM()->Disable();
915 FinishAsynchronousTest(); 913 FinishAsynchronousTest();
916 } 914 }
917 915
918 std::unique_ptr<FlatDomTreeExtractor> extractor_; 916 std::unique_ptr<FlatDomTreeExtractor> extractor_;
919 }; 917 };
920 918
921 HEADLESS_ASYNC_DEVTOOLED_TEST_F(FlatDomTreeExtractorBrowserTest); 919 HEADLESS_ASYNC_DEVTOOLED_TEST_F(FlatDomTreeExtractorBrowserTest);
922 920
923 } // namespace headless 921 } // namespace headless
OLDNEW
« no previous file with comments | « headless/public/util/flat_dom_tree_extractor.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698