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