| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 "core/html/parser/HTMLViewSourceParser.h" | 5 #include "core/html/parser/HTMLViewSourceParser.h" |
| 6 | 6 |
| 7 #include "core/dom/DocumentInit.h" | 7 #include "core/dom/DocumentInit.h" |
| 8 #include "core/dom/DocumentParser.h" | 8 #include "core/dom/DocumentParser.h" |
| 9 #include "core/html/HTMLViewSourceDocument.h" | 9 #include "core/html/HTMLViewSourceDocument.h" |
| 10 #include "platform/wtf/text/WTFString.h" |
| 10 #include "testing/gtest/include/gtest/gtest.h" | 11 #include "testing/gtest/include/gtest/gtest.h" |
| 11 #include "wtf/text/WTFString.h" | |
| 12 | 12 |
| 13 namespace blink { | 13 namespace blink { |
| 14 | 14 |
| 15 // This is a regression test for https://crbug.com/664915 | 15 // This is a regression test for https://crbug.com/664915 |
| 16 TEST(HTMLViewSourceParserTest, DetachThenFinish_ShouldNotCrash) { | 16 TEST(HTMLViewSourceParserTest, DetachThenFinish_ShouldNotCrash) { |
| 17 String mime_type("text/html"); | 17 String mime_type("text/html"); |
| 18 HTMLViewSourceDocument* document = | 18 HTMLViewSourceDocument* document = |
| 19 HTMLViewSourceDocument::Create(DocumentInit(), mime_type); | 19 HTMLViewSourceDocument::Create(DocumentInit(), mime_type); |
| 20 HTMLViewSourceParser* parser = | 20 HTMLViewSourceParser* parser = |
| 21 HTMLViewSourceParser::Create(*document, mime_type); | 21 HTMLViewSourceParser::Create(*document, mime_type); |
| 22 // A client may detach the parser from the document. | 22 // A client may detach the parser from the document. |
| 23 parser->Detach(); | 23 parser->Detach(); |
| 24 // A DocumentWriter may call finish() after detach(). | 24 // A DocumentWriter may call finish() after detach(). |
| 25 static_cast<DocumentParser*>(parser)->Finish(); | 25 static_cast<DocumentParser*>(parser)->Finish(); |
| 26 // The test passed if finish did not crash. | 26 // The test passed if finish did not crash. |
| 27 } | 27 } |
| 28 | 28 |
| 29 } // namespace blink | 29 } // namespace blink |
| OLD | NEW |