LEFT | RIGHT |
1 /* | 1 /* |
2 * This file is part of Adblock Plus <https://adblockplus.org/>, | 2 * This file is part of Adblock Plus <https://adblockplus.org/>, |
3 * Copyright (C) 2006-2016 Eyeo GmbH | 3 * Copyright (C) 2006-2016 Eyeo GmbH |
4 * | 4 * |
5 * Adblock Plus is free software: you can redistribute it and/or modify | 5 * Adblock Plus is free software: you can redistribute it and/or modify |
6 * it under the terms of the GNU General Public License version 3 as | 6 * it under the terms of the GNU General Public License version 3 as |
7 * published by the Free Software Foundation. | 7 * published by the Free Software Foundation. |
8 * | 8 * |
9 * Adblock Plus is distributed in the hope that it will be useful, | 9 * Adblock Plus is distributed in the hope that it will be useful, |
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of | 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
(...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
200 lastLogLevel = AdblockPlus::LogSystem::LOG_LEVEL_TRACE; | 200 lastLogLevel = AdblockPlus::LogSystem::LOG_LEVEL_TRACE; |
201 lastMessage.clear(); | 201 lastMessage.clear(); |
202 } | 202 } |
203 }; | 203 }; |
204 | 204 |
205 typedef std::shared_ptr<CatchLogSystem> CatchLogSystemPtr; | 205 typedef std::shared_ptr<CatchLogSystem> CatchLogSystemPtr; |
206 } | 206 } |
207 | 207 |
208 TEST_F(XMLHttpRequestTest, RequestHeaderValidation) | 208 TEST_F(XMLHttpRequestTest, RequestHeaderValidation) |
209 { | 209 { |
210 auto catchLogSystem = std::make_shared<CatchLogSystem>(); | 210 auto catchLogSystem = CatchLogSystemPtr(new CatchLogSystem()); |
211 jsEngine->SetLogSystem(catchLogSystem); | 211 jsEngine->SetLogSystem(catchLogSystem); |
212 | 212 |
213 AdblockPlus::FilterEngine filterEngine(jsEngine); | 213 AdblockPlus::FilterEngine filterEngine(jsEngine); |
214 auto webRequest = | 214 auto webRequest = |
215 std::static_pointer_cast<MockWebRequest>(jsEngine->GetWebRequest()); | 215 std::static_pointer_cast<MockWebRequest>(jsEngine->GetWebRequest()); |
216 | 216 |
217 ASSERT_TRUE(webRequest); | 217 ASSERT_TRUE(webRequest); |
218 | 218 |
219 const std::string msg = "Attempt to set a forbidden header was denied: "; | 219 const std::string msg = "Attempt to set a forbidden header was denied: "; |
220 | 220 |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
281 catchLogSystem->clear(); | 281 catchLogSystem->clear(); |
282 ResetTestXHR(jsEngine); | 282 ResetTestXHR(jsEngine); |
283 jsEngine->Evaluate("\ | 283 jsEngine->Evaluate("\ |
284 request.setRequestHeader('Security', 'theater');\nrequest.send();"); | 284 request.setRequestHeader('Security', 'theater');\nrequest.send();"); |
285 EXPECT_EQ(AdblockPlus::LogSystem::LOG_LEVEL_TRACE, catchLogSystem->lastLogLeve
l); | 285 EXPECT_EQ(AdblockPlus::LogSystem::LOG_LEVEL_TRACE, catchLogSystem->lastLogLeve
l); |
286 EXPECT_EQ("", catchLogSystem->lastMessage); | 286 EXPECT_EQ("", catchLogSystem->lastMessage); |
287 WaitForVariable("result", jsEngine); | 287 WaitForVariable("result", jsEngine); |
288 EXPECT_FALSE(webRequest->lastRequestHeaders.cend() == | 288 EXPECT_FALSE(webRequest->lastRequestHeaders.cend() == |
289 webRequest->lastRequestHeaders.find("Security")); | 289 webRequest->lastRequestHeaders.find("Security")); |
290 } | 290 } |
LEFT | RIGHT |