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

Side by Side Diff: chrome/browser/extensions/api/declarative_content/declarative_content_apitest.cc

Issue 2909523003: [Extensions Bindings] Update declarativeContent CSS validation test (Closed)
Patch Set: Created 3 years, 7 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 | « no previous file | 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 (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 "base/bind.h" 5 #include "base/bind.h"
6 #include "base/bind_helpers.h" 6 #include "base/bind_helpers.h"
7 #include "base/macros.h" 7 #include "base/macros.h"
8 #include "base/strings/stringprintf.h" 8 #include "base/strings/stringprintf.h"
9 #include "base/strings/utf_string_conversions.h" 9 #include "base/strings/utf_string_conversions.h"
10 #include "build/build_config.h" 10 #include "build/build_config.h"
(...skipping 772 matching lines...) Expand 10 before | Expand all | Expand 10 after
783 "Return(psm.css);")); 783 "Return(psm.css);"));
784 784
785 EXPECT_THAT(ExecuteScriptInBackgroundPage( 785 EXPECT_THAT(ExecuteScriptInBackgroundPage(
786 extension->id(), 786 extension->id(),
787 "try {\n" 787 "try {\n"
788 " new PageStateMatcher({css: 'Not-an-array'});\n" 788 " new PageStateMatcher({css: 'Not-an-array'});\n"
789 " Return('Failed to throw');\n" 789 " Return('Failed to throw');\n"
790 "} catch (e) {\n" 790 "} catch (e) {\n"
791 " Return(e.message);\n" 791 " Return(e.message);\n"
792 "}\n"), 792 "}\n"),
793 testing::ContainsRegex("css.*Expected 'array'")); 793 testing::ContainsRegex("css.*xpected '?array'?"));
794 EXPECT_THAT(ExecuteScriptInBackgroundPage( 794 EXPECT_THAT(ExecuteScriptInBackgroundPage(
795 extension->id(), 795 extension->id(),
796 "try {\n" 796 "try {\n"
797 " new PageStateMatcher({css: [null]});\n" // Not a string. 797 " new PageStateMatcher({css: [null]});\n" // Not a string.
798 " Return('Failed to throw');\n" 798 " Return('Failed to throw');\n"
799 "} catch (e) {\n" 799 "} catch (e) {\n"
800 " Return(e.message);\n" 800 " Return(e.message);\n"
801 "}\n"), 801 "}\n"),
802 testing::ContainsRegex("css\\.0.*Expected 'string'")); 802 testing::ContainsRegex("css.*0.*xpected '?string'?"));
803 EXPECT_THAT(ExecuteScriptInBackgroundPage( 803 EXPECT_THAT(ExecuteScriptInBackgroundPage(
804 extension->id(), 804 extension->id(),
805 "try {\n" 805 "try {\n"
806 // Invalid CSS: 806 // Invalid CSS:
807 " new PageStateMatcher({css: [\"input''\"]});\n" 807 " new PageStateMatcher({css: [\"input''\"]});\n"
808 " Return('Failed to throw');\n" 808 " Return('Failed to throw');\n"
809 "} catch (e) {\n" 809 "} catch (e) {\n"
810 " Return(e.message);\n" 810 " Return(e.message);\n"
811 "}\n"), 811 "}\n"),
812 testing::ContainsRegex("valid.*: input''$")); 812 testing::ContainsRegex("valid.*: input''$"));
813 EXPECT_THAT(ExecuteScriptInBackgroundPage( 813 EXPECT_THAT(ExecuteScriptInBackgroundPage(
814 extension->id(), 814 extension->id(),
815 "try {\n" 815 "try {\n"
816 // "Complex" selector: 816 // "Complex" selector:
817 " new PageStateMatcher({css: ['div input']});\n" 817 " new PageStateMatcher({css: ['div input']});\n"
818 " Return('Failed to throw');\n" 818 " Return('Failed to throw');\n"
819 "} catch (e) {\n" 819 "} catch (e) {\n"
820 " Return(e.message);\n" 820 " Return(e.message);\n"
821 "}\n"), 821 "}\n"),
822 testing::ContainsRegex("compound selector.*: div input$")); 822 testing::ContainsRegex("selector.*: div input$"));
823 } 823 }
824 824
825 // Tests that the rules with isBookmarked: true are evaluated when handling 825 // Tests that the rules with isBookmarked: true are evaluated when handling
826 // bookmarking events. 826 // bookmarking events.
827 IN_PROC_BROWSER_TEST_F(DeclarativeContentApiTest, 827 IN_PROC_BROWSER_TEST_F(DeclarativeContentApiTest,
828 IsBookmarkedRulesEvaluatedOnBookmarkEvents) { 828 IsBookmarkedRulesEvaluatedOnBookmarkEvents) {
829 CheckBookmarkEvents(true); 829 CheckBookmarkEvents(true);
830 } 830 }
831 831
832 // Tests that the rules with isBookmarked: false are evaluated when handling 832 // Tests that the rules with isBookmarked: false are evaluated when handling
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after
956 // action interfaces, add a test that checks that a navigation always evaluates 956 // action interfaces, add a test that checks that a navigation always evaluates
957 // consistent URL state for all conditions. i.e.: if condition1 evaluates to 957 // consistent URL state for all conditions. i.e.: if condition1 evaluates to
958 // false on url0 and true on url1, and condition2 evaluates to true on url0 and 958 // false on url0 and true on url1, and condition2 evaluates to true on url0 and
959 // false on url1, navigate from url0 to url1 and validate that no action is 959 // false on url1, navigate from url0 to url1 and validate that no action is
960 // triggered. Do the same when navigating back to url0. This kind of test is 960 // triggered. Do the same when navigating back to url0. This kind of test is
961 // unfortunately not feasible with the current implementation and the existing 961 // unfortunately not feasible with the current implementation and the existing
962 // supported conditions and actions. 962 // supported conditions and actions.
963 963
964 } // namespace 964 } // namespace
965 } // namespace extensions 965 } // namespace extensions
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698