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

Side by Side Diff: Source/bindings/core/v8/custom/V8HistoryCustom.cpp

Issue 1007113002: The history.pushState/replaceState should check for minimum arity exception. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Patch for landing Created 5 years, 9 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
« no previous file with comments | « LayoutTests/fast/history/state-object-few-arguements-exception-expected.txt ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
56 RefPtr<SerializedScriptValue> serialized = history->state(); 56 RefPtr<SerializedScriptValue> serialized = history->state();
57 value = serialized ? serialized->deserialize(info.GetIsolate()) : v8::Handle <v8::Value>(v8::Null(info.GetIsolate())); 57 value = serialized ? serialized->deserialize(info.GetIsolate()) : v8::Handle <v8::Value>(v8::Null(info.GetIsolate()));
58 V8HiddenValue::setHiddenValue(info.GetIsolate(), info.Holder(), V8HiddenValu e::state(info.GetIsolate()), value); 58 V8HiddenValue::setHiddenValue(info.GetIsolate(), info.Holder(), V8HiddenValu e::state(info.GetIsolate()), value);
59 59
60 v8SetReturnValue(info, value); 60 v8SetReturnValue(info, value);
61 } 61 }
62 62
63 void V8History::pushStateMethodCustom(const v8::FunctionCallbackInfo<v8::Value>& info) 63 void V8History::pushStateMethodCustom(const v8::FunctionCallbackInfo<v8::Value>& info)
64 { 64 {
65 ExceptionState exceptionState(ExceptionState::ExecutionContext, "pushState", "History", info.Holder(), info.GetIsolate()); 65 ExceptionState exceptionState(ExceptionState::ExecutionContext, "pushState", "History", info.Holder(), info.GetIsolate());
66
67 if (UNLIKELY(info.Length() < 2)) {
68 setMinimumArityTypeError(exceptionState, 2, info.Length());
69 exceptionState.throwIfNeeded();
70 return;
71 }
72
66 RefPtr<SerializedScriptValue> historyState = SerializedScriptValueFactory::i nstance().create(info[0], 0, 0, exceptionState, info.GetIsolate()); 73 RefPtr<SerializedScriptValue> historyState = SerializedScriptValueFactory::i nstance().create(info[0], 0, 0, exceptionState, info.GetIsolate());
67 if (exceptionState.throwIfNeeded()) 74 if (exceptionState.throwIfNeeded())
68 return; 75 return;
69 76
70 TOSTRING_VOID(V8StringResource<TreatNullAndUndefinedAsNullString>, title, in fo[1]); 77 TOSTRING_VOID(V8StringResource<TreatNullAndUndefinedAsNullString>, title, in fo[1]);
71 TOSTRING_VOID(V8StringResource<TreatNullAndUndefinedAsNullString>, url, info [2]); 78 TOSTRING_VOID(V8StringResource<TreatNullAndUndefinedAsNullString>, url, info [2]);
72 79
73 History* history = V8History::toImpl(info.Holder()); 80 History* history = V8History::toImpl(info.Holder());
74 history->stateObjectAdded(historyState.release(), title, url, FrameLoadTypeS tandard, exceptionState); 81 history->stateObjectAdded(historyState.release(), title, url, FrameLoadTypeS tandard, exceptionState);
75 V8HiddenValue::deleteHiddenValue(info.GetIsolate(), info.Holder(), V8HiddenV alue::state(info.GetIsolate())); 82 V8HiddenValue::deleteHiddenValue(info.GetIsolate(), info.Holder(), V8HiddenV alue::state(info.GetIsolate()));
76 exceptionState.throwIfNeeded(); 83 exceptionState.throwIfNeeded();
77 } 84 }
78 85
79 void V8History::replaceStateMethodCustom(const v8::FunctionCallbackInfo<v8::Valu e>& info) 86 void V8History::replaceStateMethodCustom(const v8::FunctionCallbackInfo<v8::Valu e>& info)
80 { 87 {
81 ExceptionState exceptionState(ExceptionState::ExecutionContext, "replaceStat e", "History", info.Holder(), info.GetIsolate()); 88 ExceptionState exceptionState(ExceptionState::ExecutionContext, "replaceStat e", "History", info.Holder(), info.GetIsolate());
89
90 if (UNLIKELY(info.Length() < 2)) {
91 setMinimumArityTypeError(exceptionState, 2, info.Length());
92 exceptionState.throwIfNeeded();
93 return;
94 }
95
82 RefPtr<SerializedScriptValue> historyState = SerializedScriptValueFactory::i nstance().create(info[0], 0, 0, exceptionState, info.GetIsolate()); 96 RefPtr<SerializedScriptValue> historyState = SerializedScriptValueFactory::i nstance().create(info[0], 0, 0, exceptionState, info.GetIsolate());
83 if (exceptionState.throwIfNeeded()) 97 if (exceptionState.throwIfNeeded())
84 return; 98 return;
85 99
86 TOSTRING_VOID(V8StringResource<TreatNullAndUndefinedAsNullString>, title, in fo[1]); 100 TOSTRING_VOID(V8StringResource<TreatNullAndUndefinedAsNullString>, title, in fo[1]);
87 TOSTRING_VOID(V8StringResource<TreatNullAndUndefinedAsNullString>, url, info [2]); 101 TOSTRING_VOID(V8StringResource<TreatNullAndUndefinedAsNullString>, url, info [2]);
88 102
89 History* history = V8History::toImpl(info.Holder()); 103 History* history = V8History::toImpl(info.Holder());
90 history->stateObjectAdded(historyState.release(), title, url, FrameLoadTypeR edirectWithLockedBackForwardList, exceptionState); 104 history->stateObjectAdded(historyState.release(), title, url, FrameLoadTypeR edirectWithLockedBackForwardList, exceptionState);
91 V8HiddenValue::deleteHiddenValue(info.GetIsolate(), info.Holder(), V8HiddenV alue::state(info.GetIsolate())); 105 V8HiddenValue::deleteHiddenValue(info.GetIsolate(), info.Holder(), V8HiddenV alue::state(info.GetIsolate()));
92 exceptionState.throwIfNeeded(); 106 exceptionState.throwIfNeeded();
93 } 107 }
94 108
95 } // namespace blink 109 } // namespace blink
OLDNEW
« no previous file with comments | « LayoutTests/fast/history/state-object-few-arguements-exception-expected.txt ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698