TEST(MixedContentCheckerTest, IsMixedContent) { struct TestCase { const char* origin; const char* target; bool expectation; } cases[] = { {"http://example.com/foo", "http://example.com/foo", false}, {"http://example.com/foo", "https://example.com/foo", false}, {"https://example.com/foo", "https://example.com/foo", false}, {"https://example.com/foo", "wss://example.com/foo", false}, {"https://example.com/foo", "http://example.com/foo", true}, {"https://example.com/foo", "http://google.com/foo", true}, {"https://example.com/foo", "ws://example.com/foo", true}, {"https://example.com/foo", "ws://google.com/foo", true}, }; for (size_t i = 0; i < ARRAYSIZE_UNSAFE(cases); ++i) { const char* origin = cases[i].origin; const char* target = cases[i].target; bool expectation = cases[i].expectation; KURL originUrl(KURL(), origin); RefPtr<SecurityOrigin> securityOrigin(SecurityOrigin::create(originUrl)); KURL targetUrl(KURL(), target); EXPECT_EQ(expectation, MixedContentChecker::isMixedContent(securityOrigin.get(), targetUrl)) << "Origin: " << origin << ", Target: " << target << ", Expectation: " << expectation; } }
bool MockGrammarCheck::checkGrammarOfString(const WebString& text, vector<WebTextCheckingResult>* results) { WEBKIT_ASSERT(results); string16 stringText = text; if (find_if(stringText.begin(), stringText.end(), isASCIIAlpha) == stringText.end()) return true; // Find matching grammatical errors from known ones. This function has to // check all errors because the given text may consist of two or more // sentences that have grammatical errors. static const struct { const char* text; int location; int length; } grammarErrors[] = { {"I have a issue.", 7, 1}, {"I have an grape.", 7, 2}, {"I have an kiwi.", 7, 2}, {"I have an muscat.", 7, 2}, {"You has the right.", 4, 3}, {"apple orange zz.", 0, 16}, {"apple zz orange.", 0, 16}, {"apple,zz,orange.", 0, 16}, {"orange,zz,apple.", 0, 16}, {"the the adlj adaasj sdklj. there there", 0, 38}, {"zz apple orange.", 0, 16}, }; for (size_t i = 0; i < ARRAYSIZE_UNSAFE(grammarErrors); ++i) { size_t offset = 0; string16 error(grammarErrors[i].text, grammarErrors[i].text + strlen(grammarErrors[i].text)); while ((offset = stringText.find(error, offset)) != string16::npos) { results->push_back(WebTextCheckingResult(WebTextCheckingTypeGrammar, offset + grammarErrors[i].location, grammarErrors[i].length)); offset += grammarErrors[i].length; } } return false; }