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

Side by Side Diff: Source/web/WebLocalFrameImpl.cpp

Issue 314953005: Add an ASSERT about cross-world wrapper leakage into ScriptValue (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 6 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) 2009 Google Inc. All rights reserved. 2 * Copyright (C) 2009 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 726 matching lines...) Expand 10 before | Expand all | Expand 10 after
737 { 737 {
738 if (!frame() || !frame()->script().canExecuteScripts(NotAboutToExecuteScript )) 738 if (!frame() || !frame()->script().canExecuteScripts(NotAboutToExecuteScript ))
739 return; 739 return;
740 frame()->script().bindToWindowObject(frame(), String(name), object); 740 frame()->script().bindToWindowObject(frame(), String(name), object);
741 } 741 }
742 742
743 void WebLocalFrameImpl::executeScript(const WebScriptSource& source) 743 void WebLocalFrameImpl::executeScript(const WebScriptSource& source)
744 { 744 {
745 ASSERT(frame()); 745 ASSERT(frame());
746 TextPosition position(OrdinalNumber::fromOneBasedInt(source.startLine), Ordi nalNumber::first()); 746 TextPosition position(OrdinalNumber::fromOneBasedInt(source.startLine), Ordi nalNumber::first());
747 v8::HandleScope handleScope(toIsolate(frame()));
747 frame()->script().executeScriptInMainWorld(ScriptSourceCode(source.code, sou rce.url, position)); 748 frame()->script().executeScriptInMainWorld(ScriptSourceCode(source.code, sou rce.url, position));
748 } 749 }
749 750
750 void WebLocalFrameImpl::executeScriptInIsolatedWorld(int worldID, const WebScrip tSource* sourcesIn, unsigned numSources, int extensionGroup) 751 void WebLocalFrameImpl::executeScriptInIsolatedWorld(int worldID, const WebScrip tSource* sourcesIn, unsigned numSources, int extensionGroup)
751 { 752 {
752 ASSERT(frame()); 753 ASSERT(frame());
753 RELEASE_ASSERT(worldID > 0); 754 RELEASE_ASSERT(worldID > 0);
754 RELEASE_ASSERT(worldID < EmbedderWorldIdLimit); 755 RELEASE_ASSERT(worldID < EmbedderWorldIdLimit);
755 756
756 Vector<ScriptSourceCode> sources; 757 Vector<ScriptSourceCode> sources;
757 for (unsigned i = 0; i < numSources; ++i) { 758 for (unsigned i = 0; i < numSources; ++i) {
758 TextPosition position(OrdinalNumber::fromOneBasedInt(sourcesIn[i].startL ine), OrdinalNumber::first()); 759 TextPosition position(OrdinalNumber::fromOneBasedInt(sourcesIn[i].startL ine), OrdinalNumber::first());
759 sources.append(ScriptSourceCode(sourcesIn[i].code, sourcesIn[i].url, pos ition)); 760 sources.append(ScriptSourceCode(sourcesIn[i].code, sourcesIn[i].url, pos ition));
760 } 761 }
761 762
763 v8::HandleScope handleScope(toIsolate(frame()));
762 frame()->script().executeScriptInIsolatedWorld(worldID, sources, extensionGr oup, 0); 764 frame()->script().executeScriptInIsolatedWorld(worldID, sources, extensionGr oup, 0);
763 } 765 }
764 766
765 void WebLocalFrameImpl::setIsolatedWorldSecurityOrigin(int worldID, const WebSec urityOrigin& securityOrigin) 767 void WebLocalFrameImpl::setIsolatedWorldSecurityOrigin(int worldID, const WebSec urityOrigin& securityOrigin)
766 { 768 {
767 ASSERT(frame()); 769 ASSERT(frame());
768 DOMWrapperWorld::setIsolatedWorldSecurityOrigin(worldID, securityOrigin.get( )); 770 DOMWrapperWorld::setIsolatedWorldSecurityOrigin(worldID, securityOrigin.get( ));
769 } 771 }
770 772
771 void WebLocalFrameImpl::setIsolatedWorldContentSecurityPolicy(int worldID, const WebString& policy) 773 void WebLocalFrameImpl::setIsolatedWorldContentSecurityPolicy(int worldID, const WebString& policy)
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
819 { 821 {
820 ASSERT(frame()); 822 ASSERT(frame());
821 823
822 // FIXME: This fake user gesture is required to make a bunch of pyauto 824 // FIXME: This fake user gesture is required to make a bunch of pyauto
823 // tests pass. If this isn't needed in non-test situations, we should 825 // tests pass. If this isn't needed in non-test situations, we should
824 // consider removing this code and changing the tests. 826 // consider removing this code and changing the tests.
825 // http://code.google.com/p/chromium/issues/detail?id=86397 827 // http://code.google.com/p/chromium/issues/detail?id=86397
826 UserGestureIndicator gestureIndicator(DefinitelyProcessingNewUserGesture); 828 UserGestureIndicator gestureIndicator(DefinitelyProcessingNewUserGesture);
827 829
828 TextPosition position(OrdinalNumber::fromOneBasedInt(source.startLine), Ordi nalNumber::first()); 830 TextPosition position(OrdinalNumber::fromOneBasedInt(source.startLine), Ordi nalNumber::first());
829 return frame()->script().executeScriptInMainWorldAndReturnValue(ScriptSource Code(source.code, source.url, position)).v8Value(); 831 return frame()->script().executeScriptInMainWorldAndReturnValue(ScriptSource Code(source.code, source.url, position));
830 } 832 }
831 833
832 void WebLocalFrameImpl::executeScriptInIsolatedWorld(int worldID, const WebScrip tSource* sourcesIn, unsigned numSources, int extensionGroup, WebVector<v8::Local <v8::Value> >* results) 834 void WebLocalFrameImpl::executeScriptInIsolatedWorld(int worldID, const WebScrip tSource* sourcesIn, unsigned numSources, int extensionGroup, WebVector<v8::Local <v8::Value> >* results)
833 { 835 {
834 ASSERT(frame()); 836 ASSERT(frame());
835 RELEASE_ASSERT(worldID > 0); 837 RELEASE_ASSERT(worldID > 0);
836 RELEASE_ASSERT(worldID < EmbedderWorldIdLimit); 838 RELEASE_ASSERT(worldID < EmbedderWorldIdLimit);
837 839
838 Vector<ScriptSourceCode> sources; 840 Vector<ScriptSourceCode> sources;
839 841
840 for (unsigned i = 0; i < numSources; ++i) { 842 for (unsigned i = 0; i < numSources; ++i) {
841 TextPosition position(OrdinalNumber::fromOneBasedInt(sourcesIn[i].startL ine), OrdinalNumber::first()); 843 TextPosition position(OrdinalNumber::fromOneBasedInt(sourcesIn[i].startL ine), OrdinalNumber::first());
842 sources.append(ScriptSourceCode(sourcesIn[i].code, sourcesIn[i].url, pos ition)); 844 sources.append(ScriptSourceCode(sourcesIn[i].code, sourcesIn[i].url, pos ition));
843 } 845 }
844 846
845 if (results) { 847 if (results) {
846 Vector<ScriptValue> scriptResults; 848 Vector<v8::Local<v8::Value> > scriptResults;
847 frame()->script().executeScriptInIsolatedWorld(worldID, sources, extensi onGroup, &scriptResults); 849 frame()->script().executeScriptInIsolatedWorld(worldID, sources, extensi onGroup, &scriptResults);
848 WebVector<v8::Local<v8::Value> > v8Results(scriptResults.size()); 850 WebVector<v8::Local<v8::Value> > v8Results(scriptResults.size());
849 for (unsigned i = 0; i < scriptResults.size(); i++) 851 for (unsigned i = 0; i < scriptResults.size(); i++)
850 v8Results[i] = v8::Local<v8::Value>::New(toIsolate(frame()), scriptR esults[i].v8Value()); 852 v8Results[i] = v8::Local<v8::Value>::New(toIsolate(frame()), scriptR esults[i]);
851 results->swap(v8Results); 853 results->swap(v8Results);
852 } else { 854 } else {
855 v8::HandleScope handleScope(toIsolate(frame()));
853 frame()->script().executeScriptInIsolatedWorld(worldID, sources, extensi onGroup, 0); 856 frame()->script().executeScriptInIsolatedWorld(worldID, sources, extensi onGroup, 0);
854 } 857 }
855 } 858 }
856 859
857 v8::Handle<v8::Value> WebLocalFrameImpl::callFunctionEvenIfScriptDisabled(v8::Ha ndle<v8::Function> function, v8::Handle<v8::Value> receiver, int argc, v8::Handl e<v8::Value> argv[]) 860 v8::Handle<v8::Value> WebLocalFrameImpl::callFunctionEvenIfScriptDisabled(v8::Ha ndle<v8::Function> function, v8::Handle<v8::Value> receiver, int argc, v8::Handl e<v8::Value> argv[])
858 { 861 {
859 ASSERT(frame()); 862 ASSERT(frame());
860 return frame()->script().callFunction(function, receiver, argc, argv); 863 return frame()->script().callFunction(function, receiver, argc, argv);
861 } 864 }
862 865
(...skipping 1012 matching lines...) Expand 10 before | Expand all | Expand 10 after
1875 return; 1878 return;
1876 1879
1877 RefPtrWillBeRawPtr<Document> ownerDocument(frame()->document()); 1880 RefPtrWillBeRawPtr<Document> ownerDocument(frame()->document());
1878 1881
1879 // Protect privileged pages against bookmarklets and other javascript manipu lations. 1882 // Protect privileged pages against bookmarklets and other javascript manipu lations.
1880 if (SchemeRegistry::shouldTreatURLSchemeAsNotAllowingJavascriptURLs(frame()- >document()->url().protocol())) 1883 if (SchemeRegistry::shouldTreatURLSchemeAsNotAllowingJavascriptURLs(frame()- >document()->url().protocol()))
1881 return; 1884 return;
1882 1885
1883 String script = decodeURLEscapeSequences(url.string().substring(strlen("java script:"))); 1886 String script = decodeURLEscapeSequences(url.string().substring(strlen("java script:")));
1884 UserGestureIndicator gestureIndicator(DefinitelyProcessingNewUserGesture); 1887 UserGestureIndicator gestureIndicator(DefinitelyProcessingNewUserGesture);
1885 ScriptValue result = frame()->script().executeScriptInMainWorldAndReturnValu e(ScriptSourceCode(script)); 1888 v8::HandleScope handleScope(toIsolate(frame()));
1886 1889 v8::Local<v8::Value> result = frame()->script().executeScriptInMainWorldAndR eturnValue(ScriptSourceCode(script));
1887 String scriptResult; 1890 if (result.IsEmpty() || !result->IsString())
1888 if (!result.toString(scriptResult))
1889 return; 1891 return;
1890 1892 String scriptResult = toCoreString(v8::Handle<v8::String>::Cast(result));
1891 if (!frame()->navigationScheduler().locationChangePending()) 1893 if (!frame()->navigationScheduler().locationChangePending())
1892 frame()->document()->loader()->replaceDocument(scriptResult, ownerDocume nt.get()); 1894 frame()->document()->loader()->replaceDocument(scriptResult, ownerDocume nt.get());
1893 } 1895 }
1894 1896
1895 void WebLocalFrameImpl::willDetachParent() 1897 void WebLocalFrameImpl::willDetachParent()
1896 { 1898 {
1897 // Do not expect string scoping results from any frames that got detached 1899 // Do not expect string scoping results from any frames that got detached
1898 // in the middle of the operation. 1900 // in the middle of the operation.
1899 if (m_textFinder && m_textFinder->scopingInProgress()) { 1901 if (m_textFinder && m_textFinder->scopingInProgress()) {
1900 1902
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
1942 1944
1943 void WebLocalFrameImpl::invalidateAll() const 1945 void WebLocalFrameImpl::invalidateAll() const
1944 { 1946 {
1945 ASSERT(frame() && frame()->view()); 1947 ASSERT(frame() && frame()->view());
1946 FrameView* view = frame()->view(); 1948 FrameView* view = frame()->view();
1947 view->invalidateRect(view->frameRect()); 1949 view->invalidateRect(view->frameRect());
1948 invalidateScrollbar(); 1950 invalidateScrollbar();
1949 } 1951 }
1950 1952
1951 } // namespace blink 1953 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698