blob: 93376ed91b7f977e747b877033e6cb298847f7b7 [file] [log] [blame]
<html>
<head>
<script src="resources/clearLocalStorage.js"></script>
<script>
if (window.layoutTestController) {
layoutTestController.dumpAsText();
layoutTestController.waitUntilDone();
}
function log(a)
{
document.getElementById("logger").innerHTML += a + "<br>";
}
function normalizeURL(url)
{
return url.substring(url.lastIndexOf("LayoutTests"));
}
function finish()
{
if (window.layoutTestController)
layoutTestController.notifyDone()
}
function handleStorageEvent(e)
{
log("Main Frame received StorageEvent:");
log("Key - " + e.key);
log("New Value - " + e.newValue);
log("Old Value - " + e.oldValue);
log("URI - " + normalizeURL(e.uri));
log("Source - " + normalizeURL(e.source.location.href));
log("Storage Area - " + ((e.storageArea == window.localStorage) ? "This window's window.localStorage" : "Another window's window.localStorage"));
log("");
if (e.key == "Subframe")
finish();
}
function startTest()
{
if (!window.localStorage) {
log("window.localStorage DOES NOT exist");
finish();
return;
}
window.addEventListener("storage", handleStorageEvent, false);
log("Main frame about to change localStorage...");
localStorage.setItem("Main Frame", "SET");
}
</script>
</head>
<body onload="startTest();">
This is the main frame of a 2-frame document. Each frame is in the same security origin and therefore shares the same localStorage object.
As a result, each frame should receive a StorageEvent when either frame changes the localStorage object.<br>
<iframe src="resources/iframe-events-second.html"></iframe><br>
<div id="logger"></div>
</body>
</html>