[safe-browsing] Database full hash matches like prefix match.
[chromium-blink-merge.git] / content / shell / renderer / test_runner / TestCommon.cpp
blob691ecddd8b36c4db7cdbfacac07eedd38c2519da
1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "content/shell/renderer/test_runner/TestCommon.h"
7 using namespace std;
9 namespace WebTestRunner {
11 namespace {
13 const char layoutTestsPattern[] = "/LayoutTests/";
14 const string::size_type layoutTestsPatternSize = sizeof(layoutTestsPattern) - 1;
15 const char fileUrlPattern[] = "file:/";
16 const char fileTestPrefix[] = "(file test):";
17 const char dataUrlPattern[] = "data:";
18 const string::size_type dataUrlPatternSize = sizeof(dataUrlPattern) - 1;
22 string normalizeLayoutTestURL(const string& url)
24 string result = url;
25 size_t pos;
26 if (!url.find(fileUrlPattern) && ((pos = url.find(layoutTestsPattern)) != string::npos)) {
27 // adjust file URLs to match upstream results.
28 result.replace(0, pos + layoutTestsPatternSize, fileTestPrefix);
29 } else if (!url.find(dataUrlPattern)) {
30 // URL-escape data URLs to match results upstream.
31 string path = url.substr(dataUrlPatternSize);
32 result.replace(dataUrlPatternSize, url.length(), path);
34 return result;