Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(485)

Side by Side Diff: Source/core/dom/Document.cpp

Issue 1155353002: Throw DOMException when invoked Document::execCommand on non-{X,}HTML documents (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: add test Created 5 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 /* 1 /*
2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org)
3 * (C) 1999 Antti Koivisto (koivisto@kde.org) 3 * (C) 1999 Antti Koivisto (koivisto@kde.org)
4 * (C) 2001 Dirk Mueller (mueller@kde.org) 4 * (C) 2001 Dirk Mueller (mueller@kde.org)
5 * (C) 2006 Alexey Proskuryakov (ap@webkit.org) 5 * (C) 2006 Alexey Proskuryakov (ap@webkit.org)
6 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2011, 2012 Apple Inc. All r ights reserved. 6 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2011, 2012 Apple Inc. All r ights reserved.
7 * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. (http://www.t orchmobile.com/) 7 * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. (http://www.t orchmobile.com/)
8 * Copyright (C) 2008, 2009, 2011, 2012 Google Inc. All rights reserved. 8 * Copyright (C) 2008, 2009, 2011, 2012 Google Inc. All rights reserved.
9 * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies) 9 * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies)
10 * Copyright (C) Research In Motion Limited 2010-2011. All rights reserved. 10 * Copyright (C) Research In Motion Limited 2010-2011. All rights reserved.
(...skipping 4231 matching lines...) Expand 10 before | Expand all | Expand 10 after
4242 LocalFrame* frame = document->frame(); 4242 LocalFrame* frame = document->frame();
4243 if (!frame || frame->document() != document) 4243 if (!frame || frame->document() != document)
4244 return Editor::Command(); 4244 return Editor::Command();
4245 4245
4246 document->updateLayoutTreeIfNeeded(); 4246 document->updateLayoutTreeIfNeeded();
4247 return frame->editor().command(commandName, CommandFromDOM); 4247 return frame->editor().command(commandName, CommandFromDOM);
4248 } 4248 }
4249 4249
4250 bool Document::execCommand(const String& commandName, bool, const String& value) 4250 bool Document::execCommand(const String& commandName, bool, const String& value)
4251 { 4251 {
4252 if (!isHTMLDocument() && !isXHTMLDocument())
4253 return false;
4254
4252 // We don't allow recursive |execCommand()| to protect against attack code. 4255 // We don't allow recursive |execCommand()| to protect against attack code.
4253 // Recursive call of |execCommand()| could be happened by moving iframe 4256 // Recursive call of |execCommand()| could be happened by moving iframe
4254 // with script triggered by insertion, e.g. <iframe src="javascript:..."> 4257 // with script triggered by insertion, e.g. <iframe src="javascript:...">
4255 // <iframe onload="...">. This usage is valid as of the specification 4258 // <iframe onload="...">. This usage is valid as of the specification
4256 // although, it isn't common use case, rather it is used as attack code. 4259 // although, it isn't common use case, rather it is used as attack code.
4257 static bool inExecCommand = false; 4260 static bool inExecCommand = false;
4258 if (inExecCommand) { 4261 if (inExecCommand) {
4259 String message = "We don't execute document.execCommand() this time, bec ause it is called recursively."; 4262 String message = "We don't execute document.execCommand() this time, bec ause it is called recursively.";
4260 addConsoleMessage(ConsoleMessage::create(JSMessageSource, WarningMessage Level, message)); 4263 addConsoleMessage(ConsoleMessage::create(JSMessageSource, WarningMessage Level, message));
4261 return false; 4264 return false;
(...skipping 1420 matching lines...) Expand 10 before | Expand all | Expand 10 after
5682 #ifndef NDEBUG 5685 #ifndef NDEBUG
5683 using namespace blink; 5686 using namespace blink;
5684 void showLiveDocumentInstances() 5687 void showLiveDocumentInstances()
5685 { 5688 {
5686 WeakDocumentSet& set = liveDocumentSet(); 5689 WeakDocumentSet& set = liveDocumentSet();
5687 fprintf(stderr, "There are %u documents currently alive:\n", set.size()); 5690 fprintf(stderr, "There are %u documents currently alive:\n", set.size());
5688 for (Document* document : set) 5691 for (Document* document : set)
5689 fprintf(stderr, "- Document %p URL: %s\n", document, document->url().str ing().utf8().data()); 5692 fprintf(stderr, "- Document %p URL: %s\n", document, document->url().str ing().utf8().data());
5690 } 5693 }
5691 #endif 5694 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698