From 6a00aad6ee6dc4b25b3b92db4ff36a8733a27088 Mon Sep 17 00:00:00 2001 From: Ehsan Akhgari Date: Tue, 19 Jan 2016 16:01:31 -0500 Subject: [PATCH] Bug 1209081 - Part 2: Upgrade the saved Requests in the DOM Cache to reflect the "navigate" RequestMode if they represent navigation content policy types; r=bkelly --- dom/cache/DBSchema.cpp | 36 +++++++++++++++++- dom/cache/test/xpcshell/schema_15_profile.zip | Bin 3111 -> 3111 bytes dom/cache/test/xpcshell/test_migration.js | 1 + 3 files changed, 36 insertions(+), 1 deletion(-) diff --git a/dom/cache/DBSchema.cpp b/dom/cache/DBSchema.cpp index 4558f11272c7..5edf0933fe8b 100644 --- a/dom/cache/DBSchema.cpp +++ b/dom/cache/DBSchema.cpp @@ -37,7 +37,7 @@ const int32_t kFirstShippedSchemaVersion = 15; namespace { // Update this whenever the DB schema is changed. -const int32_t kLatestSchemaVersion = 18; +const int32_t kLatestSchemaVersion = 19; // --------- // The following constants define the SQL schema. These are defined in the @@ -2412,12 +2412,14 @@ struct Migration nsresult MigrateFrom15To16(mozIStorageConnection* aConn); nsresult MigrateFrom16To17(mozIStorageConnection* aConn); nsresult MigrateFrom17To18(mozIStorageConnection* aConn); +nsresult MigrateFrom18To19(mozIStorageConnection* aConn); // Configure migration functions to run for the given starting version. Migration sMigrationList[] = { Migration(15, MigrateFrom15To16), Migration(16, MigrateFrom16To17), Migration(17, MigrateFrom17To18), + Migration(18, MigrateFrom18To19), }; uint32_t sMigrationListLength = sizeof(sMigrationList) / sizeof(Migration); @@ -2685,6 +2687,38 @@ MigrateFrom17To18(mozIStorageConnection* aConn) return rv; } +nsresult +MigrateFrom18To19(mozIStorageConnection* aConn) +{ + MOZ_ASSERT(!NS_IsMainThread()); + MOZ_ASSERT(aConn); + + mozStorageTransaction trans(aConn, true, + mozIStorageConnection::TRANSACTION_IMMEDIATE); + + // This migration is needed in order to update the RequestMode values for + // Request objects corresponding to a navigation content policy type to + // "navigate". + + static_assert(int(nsIContentPolicy::TYPE_DOCUMENT) == 6 && + int(nsIContentPolicy::TYPE_SUBDOCUMENT) == 7 && + int(nsIContentPolicy::TYPE_INTERNAL_FRAME) == 28 && + int(nsIContentPolicy::TYPE_INTERNAL_IFRAME) == 29 && + int(nsIContentPolicy::TYPE_REFRESH) == 8 && + int(RequestMode::Navigate) == 3, + "This is where the numbers below come from!"); + nsresult rv = aConn->ExecuteSimpleSQL(NS_LITERAL_CSTRING( + "UPDATE entries SET request_mode = 3 " + "WHERE request_contentpolicytype IN (6, 7, 28, 29, 8);" + )); + if (NS_WARN_IF(NS_FAILED(rv))) { return rv; } + + rv = aConn->SetSchemaVersion(19); + if (NS_WARN_IF(NS_FAILED(rv))) { return rv; } + + return rv; +} + } // anonymous namespace diff --git a/dom/cache/test/xpcshell/schema_15_profile.zip b/dom/cache/test/xpcshell/schema_15_profile.zip index 246d01e07e3f2103645513c2ebe5b6995aa67c8d..32cc8f2eeb144a881f345e1468a155a0f959a5db 100644 GIT binary patch delta 1554 zcmZ{kdpOg39LIk%wOA#iHh0g{k&epLTne>V9CA4(mt$_HhYd}xF_*Tf<2XmUX`#u; zWz?Fjkiv006emL@muAN;VRK1hx$cbTsnem^%!>%H~>0W?Ft;R19)??H=CMlh z3IY}Nt_1a$8QN;yb$)ry)5?}{qtZDNAeL(OxM^^!%&g^hLdGsOUXUb!Er%5bxr15> zU>NLZ-39RQpI5*mf>uAJrd*f|jEwe169UZ5=J*T-m8~Vr7iX|e;_&Uhq?=K$S-bAt zd~(*q@^?+L+ODe3rEWEJDA(k}+3zUk_Sc$M4;cp6C}RjYh{Xv1#jc(r!e*1s0cQI) zHXVJN{MJMUNRU{I7#1j$F(KI7r48q>`S~29h_AqH<@QEy;_LAQ9wo&wOd~9*8~-BA zD~NjF4RnDV|MWQ$&R!W|GHpfl{<7))2L_U9oDnzwhd5KGPTa$pzJ1Y@zbVQ)<@d0d zlLhl(_@Vm#=d4G8-02WqwlNVOiCLvr9K^VYbSf0hxf2srP~)J5cDzOcv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{;2WJL4#Mbr8q zK3yh9;>V986IA$m73RT!Ey{a8hhmlia9Y_0`ac*12sJs|KZfH$|K}Uy?+24>$AB4 diff --git a/dom/cache/test/xpcshell/test_migration.js b/dom/cache/test/xpcshell/test_migration.js index 5739ce25c9a6..31acc4cb7b57 100644 --- a/dom/cache/test/xpcshell/test_migration.js +++ b/dom/cache/test/xpcshell/test_migration.js @@ -21,6 +21,7 @@ function run_test() { ok(request, 'each request in list should be non-null'); ok(request.redirect === 'follow', 'request.redirect should default to "follow"'); ok(request.cache === 'default', 'request.cache should have been updated to "default"' + request.cache); + ok(request.mode === 'navigate', 'request.mode should have been updated to "navigate"'); }); return Promise.all(requestList.map(function(request) { return cache.match(request);