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

Side by Side Diff: ui/accessibility/ax_tree_fuzzer.cc

Issue 2323103002: Add fuzzer for AXTree and fix a couple of bugs it found. (Closed)
Patch Set: Created 4 years, 3 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 | « ui/accessibility/ax_tree.cc ('k') | ui/accessibility/ax_tree_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright (c) 2016 The Chromium Authors. All rights reserved.
mmoroz 2016/09/12 08:17:54 No "(c)" in copyright: https://chromium.googlesour
dmazzoni 2016/09/12 16:45:41 Done
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "ui/accessibility/ax_tree.h"
6
7 class EmptyAXTreeDelegate : public ui::AXTreeDelegate {
8 public:
9 EmptyAXTreeDelegate() {}
10
11 void OnNodeDataWillChange(ui::AXTree* tree,
12 const ui::AXNodeData& old_node_data,
13 const ui::AXNodeData& new_node_data) override {}
14 void OnTreeDataChanged(ui::AXTree* tree) override {}
15 void OnNodeWillBeDeleted(ui::AXTree* tree, ui::AXNode* node) override {}
16 void OnSubtreeWillBeDeleted(ui::AXTree* tree, ui::AXNode* node) override {}
17 void OnNodeCreated(ui::AXTree* tree, ui::AXNode* node) override {}
18 void OnNodeChanged(ui::AXTree* tree, ui::AXNode* node) override {}
19 void OnAtomicUpdateFinished(ui::AXTree* tree,
20 bool root_changed,
21 const std::vector<Change>& changes) override {}
22 };
23
24 // Entry point for LibFuzzer.
25 extern "C" int LLVMFuzzerTestOneInput(const unsigned char* data, size_t size) {
26 ui::AXTreeUpdate initial_state;
27 size_t i = 0;
28 while (i < size) {
29 ui::AXNodeData node;
30 node.id = data[i++];
31 node.state = 0;
32 if (i < size) {
33 int child_count = data[i++];
mmoroz 2016/09/12 08:17:54 Wouldn't it be better to use size_t or other unsig
dmazzoni 2016/09/12 16:45:41 You're right, good idea.
34 for (int j = 0; j < child_count && i < size; j++)
35 node.child_ids.push_back(data[i++]);
36 }
37 initial_state.nodes.push_back(node);
38 }
39
40 // Run with --v=1 to aid in debugging a specific crash.
41 VLOG(1) << "Input accessibility tree:\n" << initial_state.ToString();
42
43 ui::AXTree tree;
44 EmptyAXTreeDelegate delegate;
45 tree.SetDelegate(&delegate);
46 tree.Unserialize(initial_state);
47
48 return 0;
49 }
OLDNEW
« no previous file with comments | « ui/accessibility/ax_tree.cc ('k') | ui/accessibility/ax_tree_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698