Commit 1042fcdc authored by cmumford@chromium.org's avatar cmumford@chromium.org

Previous implementation was a DOMString. This change also validates values

when constructing IDBVersionChangeEvent instances only allowing the
correct enumeration values.

BUG=358067

Review URL: https://codereview.chromium.org/386883008

git-svn-id: svn://svn.chromium.org/blink/trunk@178517 bbb929c8-8fbe-4397-9dbb-9b2b20218538
parent 92605a32
......@@ -8,6 +8,7 @@ PASS event instanceof IDBVersionChangeEvent is true
PASS event.type is "default"
PASS event.oldVersion is 0
PASS event.newVersion is null
PASS event.dataLoss is "none"
initEvent = {oldVersion: 123, newVersion: 456}
event = new IDBVersionChangeEvent('foo', initEvent)
......@@ -15,6 +16,15 @@ PASS event instanceof IDBVersionChangeEvent is true
PASS event.type is "foo"
PASS event.oldVersion is initEvent.oldVersion
PASS event.newVersion is initEvent.newVersion
PASS event.dataLoss is "none"
initEvent = {oldVersion: 124, newVersion: 457, dataLoss: 'total'}
event = new IDBVersionChangeEvent('foo2', initEvent)
PASS event instanceof IDBVersionChangeEvent is true
PASS event.type is "foo2"
PASS event.oldVersion is initEvent.oldVersion
PASS event.newVersion is initEvent.newVersion
PASS event.dataLoss is initEvent.dataLoss
initEvent = {oldVersion: 'legacy', newVersion: null}
event = new IDBVersionChangeEvent('bar', initEvent)
......@@ -22,6 +32,7 @@ PASS event instanceof IDBVersionChangeEvent is true
PASS event.type is "bar"
PASS event.oldVersion is 0
PASS event.newVersion is null
PASS event.dataLoss is "none"
PASS successfullyParsed is true
TEST COMPLETE
......
......@@ -8,6 +8,7 @@ shouldBeTrue("event instanceof IDBVersionChangeEvent");
shouldBeEqualToString("event.type", "default");
shouldBe("event.oldVersion", "0");
shouldBe("event.newVersion", "null");
shouldBe("event.dataLoss", '"none"');
debug("");
evalAndLog("initEvent = {oldVersion: 123, newVersion: 456}");
......@@ -16,6 +17,16 @@ shouldBeTrue("event instanceof IDBVersionChangeEvent");
shouldBeEqualToString("event.type", "foo");
shouldBe("event.oldVersion", "initEvent.oldVersion");
shouldBe("event.newVersion", "initEvent.newVersion");
shouldBe("event.dataLoss", '"none"');
debug("");
evalAndLog("initEvent = {oldVersion: 124, newVersion: 457, dataLoss: 'total'}");
evalAndLog("event = new IDBVersionChangeEvent('foo2', initEvent)");
shouldBeTrue("event instanceof IDBVersionChangeEvent");
shouldBeEqualToString("event.type", "foo2");
shouldBe("event.oldVersion", "initEvent.oldVersion");
shouldBe("event.newVersion", "initEvent.newVersion");
shouldBe("event.dataLoss", "initEvent.dataLoss");
debug("");
evalAndLog("initEvent = {oldVersion: 'legacy', newVersion: null}");
......@@ -25,5 +36,6 @@ shouldBeEqualToString("event.type", "bar");
// We pull strings out of legacy databases, but don't let them be created
shouldBe("event.oldVersion", "0");
shouldBeNull("event.newVersion");
shouldBe("event.dataLoss", '"none"');
</script>
......@@ -26,8 +26,6 @@
#include "config.h"
#include "modules/indexeddb/IDBVersionChangeEvent.h"
#include "bindings/modules/v8/IDBBindingUtilities.h"
namespace blink {
......@@ -58,6 +56,10 @@ IDBVersionChangeEvent::IDBVersionChangeEvent(const AtomicString& eventType, cons
, m_newVersion(initializer.newVersion)
, m_dataLoss(blink::WebIDBDataLossNone)
{
if (initializer.dataLoss.isEmpty() || initializer.dataLoss == "none")
m_dataLoss = blink::WebIDBDataLossNone;
else if (initializer.dataLoss == "total")
m_dataLoss = blink::WebIDBDataLossTotal;
ScriptWrappable::init(this);
}
......
......@@ -43,6 +43,7 @@ struct IDBVersionChangeEventInit : public EventInit {
unsigned long long oldVersion;
Nullable<unsigned long long> newVersion;
String dataLoss;
};
class IDBVersionChangeEvent FINAL : public Event {
......@@ -77,7 +78,7 @@ private:
unsigned long long m_oldVersion;
Nullable<unsigned long long> m_newVersion;
bool m_dataLoss;
blink::WebIDBDataLoss m_dataLoss;
String m_dataLossMessage;
};
......
......@@ -23,6 +23,14 @@
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
// http://www.w3.org/TR/IndexedDB/#idl-def-IDBVersionChangeEvent
// FIXME: This enum is non-standard, see
// https://www.w3.org/Bugs/Public/show_bug.cgi?id=22370
enum IDBDataLossAmount {
"none",
"total"
};
[
EventConstructor
] interface IDBVersionChangeEvent : Event {
......@@ -31,6 +39,6 @@
// FIXME: These are non-standard, see
// https://www.w3.org/Bugs/Public/show_bug.cgi?id=22370
readonly attribute DOMString dataLoss;
[InitializedByEventConstructor] readonly attribute IDBDataLossAmount dataLoss;
readonly attribute DOMString dataLossMessage;
};
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment